index.vue 13 KB

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