index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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. logs:[]
  110. }
  111. },
  112. computed: {
  113. // 事件组合
  114. optionsEvensGroup() {
  115. if (this.pageType == 'list') {
  116. return [
  117. [
  118. [
  119. this.optionsEvensAuth('add', {
  120. click: () => {
  121. this.formDialog = true
  122. this.openForm()
  123. }
  124. })
  125. ]
  126. ]
  127. ]
  128. } else if (this.pageType == 'goodsder') {
  129. return []
  130. } else if (this.pageType == 'codeder') {
  131. return []
  132. }
  133. },
  134. // 更多参数
  135. moreParameters() {
  136. return []
  137. }
  138. },
  139. watch: {
  140. pageType() {
  141. this.handleClose()
  142. this.pageShow = false
  143. this.$nextTick(() => {
  144. this.pageShow = true
  145. })
  146. }
  147. },
  148. methods: {
  149. tishicuowu:(new delayPerform(500)).refactor(function( /**可接收参数**/ ){
  150. if(this.logs){
  151. var logs = Array.from(new Set(JSON.parse(JSON.stringify(this.logs)).map(item=>{
  152. return `${item.index!==undefined ? "第" + (item.index+1) +"行:" : ""}${item.errMsg}`
  153. })))
  154. this.logs = []
  155. this.$message({
  156. dangerouslyUseHTMLString: true,
  157. type: 'warning',
  158. message: logs.join("<div/>"),
  159. duration: 5000,
  160. });
  161. }
  162. }),
  163. changePageType() {
  164. this.goods_material_id = ''
  165. },
  166. // 列表请求函数
  167. getList(p, cb) {
  168. if (this.pageType == 'list') {
  169. return goodsPurchaseRetList(p)
  170. } else if (this.pageType == 'goodsder') {
  171. return goodsPurchaseRetItemList(p)
  172. } else if (this.pageType == 'codeder') {
  173. if (this.goods_material_id) {
  174. return goodsPurchaseRetCodeList({
  175. ...p,
  176. params: [...p.params, { param: 'b.goods_material_id', compare: '=', value: this.goods_material_id }]
  177. })
  178. } else {
  179. return goodsPurchaseRetCodeList(p)
  180. }
  181. }
  182. },
  183. // 列表导出函数
  184. exportList(...p) {
  185. if (this.pageType == 'list') {
  186. return goodsPurchaseRetListExport(...p)
  187. } else if (this.pageType == 'goodsder') {
  188. return goodsPurchaseRetItemListExport(...p)
  189. } else if (this.pageType == 'codeder') {
  190. return goodsPurchaseRetCodeListExport(...p)
  191. }
  192. },
  193. // 表格列解析渲染数据更改
  194. columnParsing(item, defaultData) {
  195. return defaultData
  196. },
  197. // 监听勾选变化
  198. selectionChange(data) {
  199. this.recordSelected = data
  200. },
  201. // 打开创建弹窗
  202. openForm() {
  203. this.isEditIndex = -1
  204. this.getGysList()
  205. this.getCgrkOrder()
  206. },
  207. // 打开详情弹窗
  208. openDetailForm(row, type) {
  209. goodsPurchaseRetDetail({ id: row.id }).then(res => {
  210. Object.assign(this.formData, res.data, {
  211. fileUrl: res.data.fileUrl ? [{ url: res.data.fileUrl }] : [],
  212. items: res.data.items.map(item => ({ ...item, details: {} }))
  213. })
  214. this.formDialogType = type
  215. this.openForm()
  216. this.formDialog = true
  217. })
  218. },
  219. handleClose() {
  220. this.$refs?.formRef?.resetFields()
  221. this.$data.formData = this.$options.data().formData
  222. this.formDialog = false
  223. this.formDialogType = 0
  224. this.activeName = 'goodsInfo'
  225. this.joinCode = false
  226. },
  227. // 操作按钮
  228. operation() {
  229. if (this.pageType == 'list') {
  230. return this.operationBtn({
  231. edit: {
  232. conditions: ({ row, index, column }) => {
  233. return row.status == 'SAVE'
  234. },
  235. click: ({ row, index, column }) => {
  236. this.openDetailForm(row, 1)
  237. }
  238. },
  239. del: {
  240. prompt: '是否确定删除',
  241. conditions: ({ row, index, column }) => {
  242. return row.status == 'SAVE'
  243. },
  244. click: ({ row, index, column }) => {
  245. goodsPurchaseRetDel({
  246. id: row.id
  247. }).then(res => {
  248. this.$message({
  249. type: 'success',
  250. message: '删除成功'
  251. })
  252. this.$refs.pageRef.refreshList()
  253. })
  254. }
  255. },
  256. detail: {
  257. click: ({ row, index, column }) => {
  258. this.openDetailForm(row, 2)
  259. }
  260. },
  261. shenhe: {
  262. conditions: ({ row, index, column }) => {
  263. return row.status == 'WAIT'
  264. },
  265. click: ({ row, index, column }) => {
  266. this.openDetailForm(row, 3)
  267. }
  268. }
  269. })
  270. } else if (this.pageType == 'goodsder') {
  271. return this.operationBtn({
  272. codeDetail: {
  273. click: ({ row, index, column }) => {
  274. this.goods_material_id = row.goodsMaterialId
  275. this.pageType = 'codeder'
  276. }
  277. }
  278. })
  279. } else if (this.pageType == 'codeder') {
  280. return undefined
  281. }
  282. },
  283. // 保存
  284. save() {
  285. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  286. if (valid) {
  287. goodsPurchaseRetAdd({
  288. ...this.formData,
  289. items: this.formData.items.map((item, index) => ({ ...item, index: index + 1 })),
  290. fileUrl: this.formData.fileUrl.map(item => item.url).join(','),
  291. codeInfoList: undefined
  292. }).then(res => {
  293. this.$message({
  294. type: 'success',
  295. message: '保存成功'
  296. })
  297. this.handleClose()
  298. this.$refs.pageRef.refreshList()
  299. })
  300. }
  301. })
  302. },
  303. // 提交
  304. submit() {
  305. goodsPurchaseRetSubmit({
  306. id: this.formData.id
  307. }).then(res => {
  308. this.$message({
  309. type: 'success',
  310. message: '提交成功'
  311. })
  312. this.handleClose()
  313. this.$refs.pageRef.refreshList()
  314. })
  315. },
  316. // 审核
  317. examine(type) {
  318. goodsPurchaseRetConfirm({
  319. id: this.formData.id,
  320. statusEnum: type
  321. }).then(res => {
  322. this.$message({
  323. type: 'success',
  324. message: '审核成功'
  325. })
  326. this.handleClose()
  327. this.$refs.pageRef.refreshList()
  328. })
  329. }
  330. }
  331. }
  332. </script>
  333. <style lang="scss" scoped>
  334. .tab {
  335. padding: 20px 20px 0 20px;
  336. }
  337. ::v-deep .teshudeshangchuananniu {
  338. color: #409eff !important;
  339. }
  340. </style>