index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <zj-tab-page ref="tabPage" :defaultActives="[{ key: 'list', label: $route.meta.title + '-列表', essential: true }]">
  3. <template slot-scope="{ activeKey, data }">
  4. <template-page
  5. v-if="activeKey == 'list'"
  6. ref="pageRef"
  7. :get-list="getList"
  8. :table-attributes="tableAttributes"
  9. :table-events="tableEvents"
  10. :options-evens-group="optionsEvensGroup"
  11. :moreParameters="moreParameters"
  12. :column-parsing="columnParsing"
  13. :operation="operation()"
  14. :exportList="exportList"
  15. >
  16. </template-page>
  17. <div v-if="~['add', 'examine', 'detail'].indexOf(activeKey)">
  18. <div style="box-sizing: border-box; padding: 20px">
  19. <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
  20. <zj-form-module
  21. title="单据信息"
  22. label-width="100px"
  23. :showPackUp="false"
  24. :form-data="formData"
  25. :form-items="formItems"
  26. >
  27. </zj-form-module>
  28. <zj-form-module
  29. title="产品信息"
  30. label-width="100px"
  31. :showPackUp="false"
  32. :form-data="formData"
  33. :form-items="formItems2"
  34. >
  35. </zj-form-module>
  36. </zj-form-container>
  37. <div slot="footer" class="dialog-footer">
  38. <el-button size="mini" @click="data.removeTab()">取 消</el-button>
  39. <el-button v-if="formDialogType !== 2" size="mini" @click="formSubmit(data.removeTab)" type="primary"
  40. >保 存</el-button
  41. >
  42. <el-button v-if="formDialogType == 1" size="mini" @click="formConfirm(data.removeTab)" type="primary"
  43. >审 核</el-button
  44. >
  45. </div>
  46. </div>
  47. </div>
  48. </template>
  49. </zj-tab-page>
  50. </template>
  51. <script>
  52. import TemplatePage from '@/components/template/template-page-1.vue'
  53. import import_mixin from '@/components/template/import_mixin.js'
  54. import { required, mobileRequired, mobile } from '@/components/template/rules_verify.js'
  55. import {
  56. goodsMoveList,
  57. goodsMoveListExport,
  58. goodsMoveAdd,
  59. goodsMoveDetail,
  60. goodsMoveConfirm,
  61. goodsMoveSubmit,
  62. goodsMoveUpdate,
  63. goodsMoveItemImportCode,
  64. goodsMoveDel,
  65. goodsMoveItemAddCode,
  66. goodsMoveItemDelCode,
  67. goodsMoveQueryExistStorageBrand,
  68. goodsMoveQueryExistStorageCategory,
  69. goodsMoveQueryExistStorageGoods,
  70. goodsMoveQueryExistStorageGoodsNum
  71. } from '@/api/GoodsTransferPeceipt'
  72. import ImageUpload from '@/components/file-upload'
  73. import operation_mixin from '@/components/template/operation_mixin.js'
  74. import editTable from '@/components/template/editTable.js'
  75. import { getWebsit } from '@/api/customerManagement.js'
  76. import { storageListPageV2 } from '@/api/storage'
  77. import { materialCategoryList } from '@/api/auxiliaryMaterialClass'
  78. import storage_goods from './storage_goods.js'
  79. import storage_table from './storage_table.js'
  80. export default {
  81. components: { TemplatePage, ImageUpload },
  82. mixins: [import_mixin, operation_mixin, storage_goods, storage_table],
  83. data() {
  84. return {
  85. // 表格属性
  86. tableAttributes: {
  87. // 启用勾选列
  88. selectColumn: false
  89. },
  90. // 表格事件
  91. tableEvents: {
  92. 'selection-change': this.selectionChange
  93. },
  94. // 勾选选中行
  95. recordSelected: [],
  96. /** 表单变量 */
  97. formDialogType: 0,
  98. formDialogTitles: ['新增', '审核', '查看'],
  99. formData: {
  100. companyWechatId: '',
  101. companyWechatName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  102. examineBy: '',
  103. examineTime: '',
  104. inStorageId: '',
  105. inStorageName: '',
  106. items: [],
  107. outStorageId: '',
  108. outStorageName: '',
  109. remark: '',
  110. status: '',
  111. submitBy: '',
  112. submitTime: '',
  113. totalQty: '',
  114. type: 'G',
  115. websitId: '',
  116. websitName: ''
  117. },
  118. websitSelectList: [],
  119. warehouseList: []
  120. }
  121. },
  122. computed: {
  123. // 事件组合
  124. optionsEvensGroup() {
  125. return [
  126. [
  127. [
  128. this.optionsEvensAuth('add', {
  129. click: () => {
  130. this.openForm('add')
  131. }
  132. })
  133. ]
  134. ]
  135. ]
  136. },
  137. // 更多参数
  138. moreParameters() {
  139. return []
  140. },
  141. formItems() {
  142. return [
  143. {
  144. md: 6,
  145. isShow: true,
  146. name: 'el-select',
  147. options: [
  148. { label: '保存', value: 'SAVE' },
  149. { label: '待审核', value: 'WAIT' },
  150. { label: '通过', value: 'OK' },
  151. { label: '失败', value: 'FAIL' }
  152. ],
  153. attributes: { disabled: true },
  154. formItemAttributes: {
  155. label: '单据状态',
  156. prop: 'status',
  157. rules: []
  158. }
  159. },
  160. {
  161. md: 6,
  162. isShow: true,
  163. name: 'el-input',
  164. attributes: { placeholder: '', disabled: true },
  165. formItemAttributes: {
  166. label: '单据编号',
  167. prop: 'id',
  168. rules: []
  169. }
  170. },
  171. {
  172. md: 6,
  173. isShow: true,
  174. name: 'el-input',
  175. attributes: { placeholder: '请输入', disabled: true },
  176. formItemAttributes: {
  177. label: '所属商户',
  178. prop: 'companyWechatName',
  179. rules: []
  180. }
  181. },
  182. // {
  183. // md: 6,
  184. // isShow: true,
  185. // name: 'el-select',
  186. // options: this.websitSelectList.map(item => ({ label: item.name, value: item.websitId })),
  187. // attributes: {},
  188. // formItemAttributes: {
  189. // label: '网点名称',
  190. // prop: 'websitId',
  191. // rules: [...required]
  192. // }
  193. // },
  194. {
  195. md: 6,
  196. name: 'el-radio',
  197. options: [
  198. { label: '商品', value: 'G' }
  199. // { label: '辅材', value: 'M' },
  200. // { label: '辅材', value: 'P' }
  201. ],
  202. attributes: {
  203. disabled: this.formDialogType == 2
  204. },
  205. formItemAttributes: {
  206. label: '调仓产品',
  207. prop: 'type',
  208. rules: [...required]
  209. }
  210. },
  211. {
  212. md: 6,
  213. isShow: true,
  214. name: 'el-select',
  215. options: this.warehouseList
  216. .map(item => ({ label: item.storageName, value: item.storageId }))
  217. .filter(item => item.value !== this.formData.inStorageId),
  218. attributes: {
  219. disabled: this.formDialogType == 2
  220. },
  221. formItemAttributes: {
  222. label: '调出仓库',
  223. prop: 'outStorageId',
  224. rules: [...required]
  225. }
  226. },
  227. {
  228. md: 6,
  229. isShow: true,
  230. name: 'el-select',
  231. options: this.warehouseList
  232. .map(item => ({ label: item.storageName, value: item.storageId }))
  233. .filter(item => item.value !== this.formData.outStorageId),
  234. attributes: {
  235. disabled: this.formDialogType == 2
  236. },
  237. formItemAttributes: {
  238. label: '调入仓库',
  239. prop: 'inStorageId',
  240. rules: [...required]
  241. }
  242. },
  243. {
  244. md: 12,
  245. isShow: true,
  246. name: 'slot-component',
  247. attributes: { placeholder: '' },
  248. formItemAttributes: {
  249. label: '',
  250. prop: '',
  251. 'label-width': '0px'
  252. },
  253. render: (h, { props, onInput }) => {
  254. return <div></div>
  255. }
  256. },
  257. {
  258. md: 6,
  259. isShow: true,
  260. name: 'el-input',
  261. attributes: { placeholder: '请输入', disabled: true },
  262. formItemAttributes: {
  263. label: '制单人',
  264. prop: 'createBy',
  265. rules: []
  266. }
  267. },
  268. {
  269. md: 6,
  270. isShow: true,
  271. name: 'el-input',
  272. attributes: { placeholder: '请输入', disabled: true },
  273. formItemAttributes: {
  274. label: '制单时间',
  275. prop: 'createTime',
  276. rules: []
  277. }
  278. },
  279. {
  280. md: 6,
  281. isShow: true,
  282. name: 'el-input',
  283. attributes: { placeholder: '请输入', disabled: true },
  284. formItemAttributes: {
  285. label: '审核人',
  286. prop: 'examineBy',
  287. rules: []
  288. }
  289. },
  290. {
  291. md: 6,
  292. isShow: true,
  293. name: 'el-input',
  294. attributes: { placeholder: '请输入', disabled: true },
  295. formItemAttributes: {
  296. label: '审核时间',
  297. prop: 'examineTime',
  298. rules: []
  299. }
  300. },
  301. {
  302. md: 24,
  303. isShow: true,
  304. name: 'el-input',
  305. attributes: { placeholder: '请输入', type: 'textarea', rows: 5, disabled: this.formDialogType == 2 },
  306. formItemAttributes: {
  307. label: '备注',
  308. prop: 'remark',
  309. rules: []
  310. }
  311. }
  312. ]
  313. }
  314. },
  315. methods: {
  316. // 列表请求函数
  317. getList: goodsMoveList,
  318. // 列表导出函数
  319. exportList: goodsMoveListExport,
  320. // 表格列解析渲染数据更改
  321. columnParsing(item, defaultData) {
  322. return defaultData
  323. },
  324. // 监听勾选变化
  325. selectionChange(data) {
  326. this.recordSelected = data
  327. },
  328. // 表格操作列
  329. operation() {
  330. return this.operationBtn({
  331. view: {
  332. btnType: 'text',
  333. click: ({ row, index, column }) => {
  334. this.openForm('detail', row.id)
  335. }
  336. },
  337. examine: {
  338. btnType: 'text',
  339. conditions: ({ row, index, column }) => {
  340. return row.status !== 'OK'
  341. },
  342. click: ({ row, index, column }) => {
  343. this.openForm('examine', row.id)
  344. }
  345. }
  346. })
  347. },
  348. // 取消 新增编辑
  349. formCancel() {
  350. this.$refs?.formRef?.resetFields()
  351. this.$data.formData = this.$options.data().formData
  352. },
  353. // 打开 新增编辑 网点表单
  354. openForm(type, id) {
  355. this.$refs.tabPage.addTab({
  356. // 对应显示的模块
  357. activeKey: type,
  358. // 唯一标识
  359. key: type,
  360. // 页签名称
  361. label: { examine: '审核', add: '新增', detail: '查看' }[type],
  362. // 打开时事件
  363. triggerEvent: () => {
  364. this.formCancel()
  365. this.$nextTick(() => {
  366. if (type == 'add') {
  367. this.formDialogType = 0
  368. this.initData()
  369. } else if (type == 'examine') {
  370. this.formDialogType = 1
  371. goodsMoveDetail({ id }).then(res => {
  372. Object.assign(this.formData, res.data)
  373. this.initData()
  374. })
  375. } else {
  376. this.formDialogType = 2
  377. goodsMoveDetail({ id }).then(res => {
  378. Object.assign(this.formData, res.data)
  379. this.initData()
  380. })
  381. }
  382. })
  383. },
  384. // 关闭时事件
  385. closeEvent: () => {}
  386. })
  387. },
  388. initData() {
  389. this.getBaseList()
  390. Promise.all([
  391. getWebsit({ type: 'C', status: true }),
  392. storageListPageV2({
  393. pageNum: 1,
  394. pageSize: -1,
  395. params: [
  396. { param: 'a.type', compare: 'like', value: '商品' },
  397. { param: 'a.status', compare: '=', value: 'true' }
  398. ]
  399. })
  400. ]).then(([res1, res2]) => {
  401. this.websitSelectList = res1.data
  402. this.warehouseList = res2.data.records
  403. })
  404. },
  405. formSubmit(cancel) {
  406. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  407. if (valid) {
  408. if (this.formDialogType == 0) {
  409. goodsMoveAdd({ ...this.formData }).then(res => {
  410. this.$message({
  411. type: 'success',
  412. message: `保存成功!`
  413. })
  414. cancel('list')
  415. this.$refs.pageRef.refreshList()
  416. })
  417. } else if (this.formDialogType == 1) {
  418. goodsMoveUpdate({ ...this.formData }).then(res => {
  419. this.$message({
  420. type: 'success',
  421. message: `保存成功!`
  422. })
  423. cancel('list')
  424. this.$refs.pageRef.refreshList()
  425. })
  426. }
  427. }
  428. })
  429. },
  430. formConfirm(cancel) {
  431. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  432. if (valid) {
  433. if (this.formData.status == 'WAIT') {
  434. goodsMoveConfirm({ id: this.formData.id, statusEnum: 'OK' }).then(res => {
  435. this.$message({
  436. type: 'success',
  437. message: `审核成功!`
  438. })
  439. cancel('list')
  440. this.$refs.pageRef.refreshList()
  441. // 备注
  442. })
  443. } else {
  444. goodsMoveUpdate({ ...this.formData }).then(res => {
  445. goodsMoveSubmit({ id: this.formData.id }).then(res => {
  446. goodsMoveConfirm({ id: this.formData.id, statusEnum: 'OK' }).then(res => {
  447. this.$message({
  448. type: 'success',
  449. message: `审核成功!`
  450. })
  451. cancel('list')
  452. this.$refs.pageRef.refreshList()
  453. // 备注
  454. })
  455. })
  456. })
  457. }
  458. }
  459. })
  460. }
  461. }
  462. }
  463. </script>
  464. <style lang="scss" scoped></style>