index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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.items = []
  213. }
  214. }
  215. },
  216. {
  217. md: 6,
  218. isShow: true,
  219. name: 'el-select',
  220. options: this.warehouseList
  221. .map(item => ({ label: item.storageName, value: item.storageId }))
  222. .filter(item => item.value !== this.formData.inStorageId),
  223. attributes: {
  224. disabled: this.formDialogType == 2
  225. },
  226. formItemAttributes: {
  227. label: '调出仓库',
  228. prop: 'outStorageId',
  229. rules: [...required]
  230. },
  231. events: {
  232. change: () => {
  233. this.formData.items = []
  234. }
  235. }
  236. },
  237. {
  238. md: 6,
  239. isShow: true,
  240. name: 'el-select',
  241. options: this.warehouseList
  242. .map(item => ({ label: item.storageName, value: item.storageId }))
  243. .filter(item => item.value !== this.formData.outStorageId),
  244. attributes: {
  245. disabled: this.formDialogType == 2
  246. },
  247. formItemAttributes: {
  248. label: '调入仓库',
  249. prop: 'inStorageId',
  250. rules: [...required]
  251. },
  252. events: {
  253. change: () => {
  254. this.formData.items = []
  255. }
  256. }
  257. },
  258. {
  259. md: 6,
  260. isShow: true,
  261. name: 'slot-component',
  262. attributes: { placeholder: '' },
  263. formItemAttributes: {
  264. label: '',
  265. prop: '',
  266. 'label-width': '0px'
  267. },
  268. render: (h, { props, onInput }) => {
  269. return <div></div>
  270. }
  271. },
  272. {
  273. md: 6,
  274. isShow: true,
  275. name: 'el-input',
  276. attributes: { placeholder: '请输入', disabled: true },
  277. formItemAttributes: {
  278. label: '制单人',
  279. prop: 'createBy',
  280. rules: []
  281. }
  282. },
  283. {
  284. md: 6,
  285. isShow: true,
  286. name: 'el-input',
  287. attributes: { placeholder: '请输入', disabled: true },
  288. formItemAttributes: {
  289. label: '制单时间',
  290. prop: 'createTime',
  291. rules: []
  292. }
  293. },
  294. {
  295. md: 6,
  296. isShow: true,
  297. name: 'el-input',
  298. attributes: { placeholder: '请输入', disabled: true },
  299. formItemAttributes: {
  300. label: '审核人',
  301. prop: 'examineBy',
  302. rules: []
  303. }
  304. },
  305. {
  306. md: 6,
  307. isShow: true,
  308. name: 'el-input',
  309. attributes: { placeholder: '请输入', disabled: true },
  310. formItemAttributes: {
  311. label: '审核时间',
  312. prop: 'examineTime',
  313. rules: []
  314. }
  315. },
  316. {
  317. md: 24,
  318. isShow: true,
  319. name: 'el-input',
  320. attributes: { placeholder: '请输入', type: 'textarea', rows: 5, disabled: this.formDialogType == 2 },
  321. formItemAttributes: {
  322. label: '备注',
  323. prop: 'remark',
  324. rules: []
  325. }
  326. }
  327. ]
  328. }
  329. },
  330. methods: {
  331. // 列表请求函数
  332. getList: websitGoodsMoveList,
  333. // 列表导出函数
  334. exportList: websitGoodsMoveListExport,
  335. // 表格列解析渲染数据更改
  336. columnParsing(item, defaultData) {
  337. return defaultData
  338. },
  339. // 监听勾选变化
  340. selectionChange(data) {
  341. this.recordSelected = data
  342. },
  343. // 表格操作列
  344. operation() {
  345. return this.operationBtn({
  346. view: {
  347. btnType: 'text',
  348. click: ({ row, index, column }) => {
  349. this.openForm('detail', row.id)
  350. }
  351. },
  352. examine: {
  353. btnType: 'text',
  354. conditions: ({ row, index, column }) => {
  355. return row.status !== 'OK'
  356. },
  357. click: ({ row, index, column }) => {
  358. this.openForm('examine', row.id)
  359. }
  360. }
  361. })
  362. },
  363. // 取消 新增编辑
  364. formCancel() {
  365. this.$refs?.formRef?.resetFields()
  366. this.$data.formData = this.$options.data().formData
  367. },
  368. // 打开 新增编辑 网点表单
  369. openForm(type, id) {
  370. this.$refs.tabPage.addTab({
  371. // 对应显示的模块
  372. activeKey: type,
  373. // 唯一标识
  374. key: type,
  375. // 页签名称
  376. label: { examine: '审核', add: '新增', detail: '查看' }[type],
  377. // 打开时事件
  378. triggerEvent: () => {
  379. this.formCancel()
  380. this.$nextTick(() => {
  381. if (type == 'add') {
  382. this.formDialogType = 0
  383. this.initData()
  384. } else if (type == 'examine') {
  385. this.formDialogType = 1
  386. websitGoodsMoveDetail({ id }).then(res => {
  387. Object.assign(this.formData, res.data)
  388. this.initData()
  389. })
  390. } else {
  391. this.formDialogType = 2
  392. websitGoodsMoveDetail({ id }).then(res => {
  393. Object.assign(this.formData, res.data)
  394. this.initData()
  395. })
  396. }
  397. })
  398. },
  399. // 关闭时事件
  400. closeEvent: () => {}
  401. })
  402. },
  403. initData() {
  404. Promise.all([getWebsit({ type: 'C', status: true })]).then(([res1]) => {
  405. this.websitSelectList = res1.data
  406. this.biyaowebsitId(this.formData.websitId)
  407. this.biyaooutStorageId(this.formData.outStorageId)
  408. this.biyaooutwarehouseList()
  409. })
  410. },
  411. formSubmit(cancel) {
  412. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  413. if (valid) {
  414. if (this.formDialogType == 0) {
  415. websitGoodsMoveAdd({ ...this.formData }).then(res => {
  416. this.$message({
  417. type: 'success',
  418. message: `保存成功!`
  419. })
  420. cancel('list')
  421. this.$refs.pageRef.refreshList()
  422. })
  423. } else if (this.formDialogType == 1) {
  424. websitGoodsMoveAdd({ ...this.formData }).then(res => {
  425. this.$message({
  426. type: 'success',
  427. message: `保存成功!`
  428. })
  429. cancel('list')
  430. this.$refs.pageRef.refreshList()
  431. })
  432. }
  433. }
  434. })
  435. },
  436. formConfirm(cancel) {
  437. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  438. if (valid) {
  439. if (this.formData.status == 'WAIT') {
  440. websitGoodsMoveConfirm({ id: this.formData.id, statusEnum: 'OK' }).then(res => {
  441. this.$message({
  442. type: 'success',
  443. message: `审核成功!`
  444. })
  445. cancel('list')
  446. this.$refs.pageRef.refreshList()
  447. // 备注
  448. })
  449. } else {
  450. websitGoodsMoveAdd({ ...this.formData }).then(res => {
  451. websitGoodsMoveSubmit({ id: this.formData.id }).then(res => {
  452. websitGoodsMoveConfirm({ id: this.formData.id, statusEnum: 'OK' }).then(res => {
  453. this.$message({
  454. type: 'success',
  455. message: `审核成功!`
  456. })
  457. cancel('list')
  458. this.$refs.pageRef.refreshList()
  459. // 备注
  460. })
  461. })
  462. })
  463. }
  464. }
  465. })
  466. }
  467. }
  468. }
  469. </script>
  470. <style lang="scss" scoped></style>