index.vue 14 KB

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