index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <template-page v-if="pageShow" ref="pageRef" :get-list="getList" :table-attributes="tableAttributes"
  3. :table-events="tableEvents" :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters"
  4. :column-parsing="columnParsing" :exportList="exportList" :operation="operation()" key="pageType">
  5. <div slot="moreSearch">
  6. <el-radio-group v-model="pageType" size="mini" @change="changePageType">
  7. <el-radio-button label="list">列表</el-radio-button>
  8. <el-radio-button label="goodsder">商品明细</el-radio-button>
  9. <el-radio-button label="codeder">条码明细</el-radio-button>
  10. </el-radio-group>
  11. <br /><br />
  12. </div>
  13. <div class="cartographer_big">
  14. <el-dialog :title="formDialogTitles[formDialogType]" width="100%" :modal="false" :visible.sync="formDialog"
  15. :before-close="handleClose">
  16. <zj-page-container>
  17. <zj-page-fill>
  18. <div style="box-sizing: border-box; padding: 20px 20px 0 20px">
  19. <zj-form-container ref="formRef" :form-data="formData" :form-attributes="{ size: 'mini' }">
  20. <zj-form-module title="单据信息" label-width="100px" :form-data="formData" :form-items="formItems">
  21. </zj-form-module>
  22. <zj-form-module title="" label-width="100px" :form-data="formData" :form-items="formItems2">
  23. <el-tabs slot="header" v-model="activeName">
  24. <el-tab-pane label="商品信息" name="goodsInfo"></el-tab-pane>
  25. <el-tab-pane v-if="formDialogType > 0 && joinCode" label="条码信息" name="codeInfo"></el-tab-pane>
  26. </el-tabs>
  27. </zj-form-module>
  28. </zj-form-container>
  29. </div>
  30. </zj-page-fill>
  31. <div v-if="activeName == 'goodsInfo'" style="text-align: right; box-sizing: border-box; padding: 16px 20px">
  32. <el-button v-if="formDialogType == 0" size="mini" type="primary" @click="save">保存</el-button>
  33. <el-button v-if="formDialogType == 1" size="mini" type="primary" @click="submit">提交</el-button>
  34. <el-button v-if="formDialogType == 3" size="mini" type="primary" @click="examine('OK')">审核通过</el-button>
  35. <el-button v-if="formDialogType == 3" size="mini" type="primary" @click="examine('FAIL')">审核驳回</el-button>
  36. </div>
  37. </zj-page-container>
  38. </el-dialog>
  39. </div>
  40. </template-page>
  41. </template>
  42. <script>
  43. import TemplatePage from '@/components/template/template-page-1.vue'
  44. import import_mixin from '@/components/template/import_mixin.js'
  45. import operation_mixin from '@/components/template/operation_mixin.js'
  46. import {
  47. goodsPurchaseRetList,
  48. goodsPurchaseRetListExport,
  49. goodsPurchaseRetItemList,
  50. goodsPurchaseRetItemListExport,
  51. goodsPurchaseRetCodeList,
  52. goodsPurchaseRetCodeListExport,
  53. goodsPurchaseRetAdd,
  54. goodsPurchaseRetSubmit,
  55. goodsPurchaseRetConfirm,
  56. goodsPurchaseRetDetail,
  57. goodsPurchaseRetDel
  58. } from '@/api/merchandisePurchaseReturn.js'
  59. import form_ty from '../mixins/common_form'
  60. import out_storage_table from '../mixins/out_storage_table'
  61. import out_storage_goods from '../mixins/out_storage_goods'
  62. import out_storage_codes from '../mixins/out_storage_codes'
  63. import common from '../mixins/common_code'
  64. import { delayPerform, firstPerform, intervalPerform, passivePerform, queuePerform } from "js-perform-lock";
  65. export default {
  66. components: { TemplatePage },
  67. mixins: [import_mixin, operation_mixin, form_ty, out_storage_table, out_storage_goods, out_storage_codes, common],
  68. data() {
  69. return {
  70. pageType: 'list',
  71. pageShow: true,
  72. // 表格属性
  73. tableAttributes: {
  74. // 启用勾选列
  75. selectColumn: false
  76. },
  77. // 表格事件
  78. tableEvents: {
  79. 'selection-change': this.selectionChange
  80. },
  81. // 勾选选中行
  82. recordSelected: [],
  83. /** 表单变量 */
  84. formDialogType: 0,
  85. formDialogTitles: ['新增退货单', '编辑退货单', '退货单详情', '审核退货单'],
  86. formDialog: false,
  87. appraise_status: '',
  88. formData: {
  89. companyWechatId: '',
  90. companyWechatName: '',
  91. examineBy: '',
  92. examineTime: '',
  93. fileUrl: [],
  94. goodsPurchaseId: '',
  95. items: [],
  96. remark: '',
  97. status: '',
  98. submitBy: '',
  99. submitTime: '',
  100. totalAmount: '',
  101. totalQty: '',
  102. venderId: '',
  103. venderName: '',
  104. codeInfoList: []
  105. },
  106. activeName: 'goodsInfo',
  107. goods_material_id: '',
  108. joinCode: false,
  109. joinCodeText: JSON.parse(localStorage.getItem('greemall_user')).joinCode,
  110. logs:[]
  111. }
  112. },
  113. computed: {
  114. // 事件组合
  115. optionsEvensGroup() {
  116. if (this.pageType == 'list') {
  117. return [
  118. [
  119. [
  120. this.optionsEvensAuth('add', {
  121. click: () => {
  122. this.formDialog = true
  123. this.openForm()
  124. }
  125. })
  126. ]
  127. ]
  128. ]
  129. } else if (this.pageType == 'goodsder') {
  130. return []
  131. } else if (this.pageType == 'codeder') {
  132. return []
  133. }
  134. },
  135. // 更多参数
  136. moreParameters() {
  137. return []
  138. }
  139. },
  140. watch: {
  141. pageType() {
  142. this.handleClose()
  143. this.pageShow = false
  144. this.$nextTick(() => {
  145. this.pageShow = true
  146. })
  147. }
  148. },
  149. methods: {
  150. tishicuowu:(new delayPerform(500)).refactor(function( /**可接收参数**/ ){
  151. if(this.logs){
  152. var logs = Array.from(new Set(JSON.parse(JSON.stringify(this.logs)).map(item=>{
  153. return `${item.index!==undefined ? "第" + (item.index+1) +"行:" : ""}${item.errMsg}`
  154. })))
  155. this.logs = []
  156. this.$message({
  157. dangerouslyUseHTMLString: true,
  158. type: 'warning',
  159. message: logs.join("<div/>"),
  160. duration: 5000,
  161. });
  162. }
  163. }),
  164. changePageType() {
  165. this.goods_material_id = ''
  166. },
  167. // 列表请求函数
  168. getList(p, cb) {
  169. if (this.pageType == 'list') {
  170. return goodsPurchaseRetList(p)
  171. } else if (this.pageType == 'goodsder') {
  172. return goodsPurchaseRetItemList(p)
  173. } else if (this.pageType == 'codeder') {
  174. if (this.goods_material_id) {
  175. return goodsPurchaseRetCodeList({
  176. ...p,
  177. params: [...p.params, { param: 'b.goods_material_id', compare: '=', value: this.goods_material_id }]
  178. })
  179. } else {
  180. return goodsPurchaseRetCodeList(p)
  181. }
  182. }
  183. },
  184. // 列表导出函数
  185. exportList(...p) {
  186. if (this.pageType == 'list') {
  187. return goodsPurchaseRetListExport(...p)
  188. } else if (this.pageType == 'goodsder') {
  189. return goodsPurchaseRetItemListExport(...p)
  190. } else if (this.pageType == 'codeder') {
  191. return goodsPurchaseRetCodeListExport(...p)
  192. }
  193. },
  194. // 表格列解析渲染数据更改
  195. columnParsing(item, defaultData) {
  196. return defaultData
  197. },
  198. // 监听勾选变化
  199. selectionChange(data) {
  200. this.recordSelected = data
  201. },
  202. // 打开创建弹窗
  203. openForm() {
  204. this.isEditIndex = -1
  205. this.getGysList()
  206. this.getWarehouseList()
  207. this.getCgrkOrder()
  208. },
  209. // 打开详情弹窗
  210. openDetailForm(row, type) {
  211. goodsPurchaseRetDetail({ id: row.id }).then(res => {
  212. Object.assign(this.formData, res.data, {
  213. fileUrl: res.data.fileUrl ? [{ url: res.data.fileUrl }] : [],
  214. items: res.data.items.map(item => ({ ...item, details: {} }))
  215. })
  216. this.formDialogType = type
  217. this.openForm()
  218. this.formDialog = true
  219. })
  220. },
  221. handleClose() {
  222. this.$refs?.formRef?.resetFields()
  223. this.$data.formData = this.$options.data().formData
  224. this.formDialog = false
  225. this.formDialogType = 0
  226. this.activeName = 'goodsInfo'
  227. this.joinCode = false
  228. },
  229. // 操作按钮
  230. operation() {
  231. if (this.pageType == 'list') {
  232. return this.operationBtn({
  233. edit: {
  234. conditions: ({ row, index, column }) => {
  235. return row.status == 'SAVE'
  236. },
  237. click: ({ row, index, column }) => {
  238. this.openDetailForm(row, 1)
  239. }
  240. },
  241. del: {
  242. prompt: '是否确定删除',
  243. conditions: ({ row, index, column }) => {
  244. return row.status == 'SAVE'
  245. },
  246. click: ({ row, index, column }) => {
  247. goodsPurchaseRetDel({
  248. id: row.id
  249. }).then(res => {
  250. this.$message({
  251. type: 'success',
  252. message: '删除成功'
  253. })
  254. this.$refs.pageRef.refreshList()
  255. })
  256. }
  257. },
  258. detail: {
  259. click: ({ row, index, column }) => {
  260. this.openDetailForm(row, 2)
  261. }
  262. },
  263. shenhe: {
  264. conditions: ({ row, index, column }) => {
  265. return row.status == 'WAIT'
  266. },
  267. click: ({ row, index, column }) => {
  268. this.openDetailForm(row, 3)
  269. }
  270. }
  271. })
  272. } else if (this.pageType == 'goodsder') {
  273. return this.operationBtn({
  274. codeDetail: {
  275. click: ({ row, index, column }) => {
  276. this.goods_material_id = row.goodsMaterialId
  277. this.pageType = 'codeder'
  278. }
  279. }
  280. })
  281. } else if (this.pageType == 'codeder') {
  282. return undefined
  283. }
  284. },
  285. // 保存
  286. save() {
  287. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  288. if (valid) {
  289. goodsPurchaseRetAdd({
  290. ...this.formData,
  291. items: this.formData.items.map((item, index) => ({ ...item, index: index + 1 })),
  292. fileUrl: this.formData.fileUrl.map(item => item.url).join(','),
  293. codeInfoList: undefined
  294. }).then(res => {
  295. this.$message({
  296. type: 'success',
  297. message: '保存成功'
  298. })
  299. this.handleClose()
  300. this.$refs.pageRef.refreshList()
  301. })
  302. }
  303. })
  304. },
  305. // 提交
  306. submit() {
  307. goodsPurchaseRetSubmit({
  308. id: this.formData.id
  309. }).then(res => {
  310. this.$message({
  311. type: 'success',
  312. message: '提交成功'
  313. })
  314. this.handleClose()
  315. this.$refs.pageRef.refreshList()
  316. })
  317. },
  318. // 审核
  319. examine(type) {
  320. goodsPurchaseRetConfirm({
  321. id: this.formData.id,
  322. statusEnum: type
  323. }).then(res => {
  324. this.$message({
  325. type: 'success',
  326. message: '审核成功'
  327. })
  328. this.handleClose()
  329. this.$refs.pageRef.refreshList()
  330. })
  331. }
  332. }
  333. }
  334. </script>
  335. <style lang="scss" scoped>
  336. .tab {
  337. padding: 20px 20px 0 20px;
  338. }
  339. ::v-deep .teshudeshangchuananniu {
  340. color: #409eff !important;
  341. }
  342. </style>