index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. <template>
  2. <template-page
  3. v-if="pageShow"
  4. ref="pageRef"
  5. :get-list="getList"
  6. :table-attributes="tableAttributes"
  7. :table-events="tableEvents"
  8. :options-evens-group="optionsEvensGroup"
  9. :moreParameters="moreParameters"
  10. :column-parsing="columnParsing"
  11. :exportList="exportList"
  12. :operation="operation()"
  13. key="pageType"
  14. >
  15. <div slot="moreSearch">
  16. <el-radio-group v-model="pageType" size="mini" @input="changePageType">
  17. <el-radio-button label="list">列表</el-radio-button>
  18. <el-radio-button label="goodsder">商品明细</el-radio-button>
  19. <el-radio-button label="codeder">条码明细</el-radio-button>
  20. </el-radio-group>
  21. <br /><br />
  22. </div>
  23. <div class="cartographer_big">
  24. <el-dialog
  25. :title="formDialogTitles[formDialogType]"
  26. width="100%"
  27. :modal="false"
  28. :visible.sync="formDialog"
  29. :before-close="handleClose"
  30. >
  31. <zj-page-container>
  32. <zj-page-fill>
  33. <div style="box-sizing: border-box; padding: 20px 20px 0 20px">
  34. <zj-form-container ref="formRef" :form-data="formData" :form-attributes="{ size: 'mini' }">
  35. <zj-form-module title="单据信息" label-width="100px" :form-data="formData" :form-items="formItems">
  36. </zj-form-module>
  37. <zj-form-module title="" label-width="100px" :form-data="formData" :form-items="formItems2">
  38. <el-tabs slot="header" v-model="activeName">
  39. <el-tab-pane label="商品信息" name="goodsInfo"></el-tab-pane>
  40. <el-tab-pane v-if="formDialogType > 0 && joinCode" label="条码信息" name="codeInfo"></el-tab-pane>
  41. </el-tabs>
  42. </zj-form-module>
  43. <zj-form-module
  44. v-if="formData.isPlan"
  45. title="计划单明细"
  46. label-width="100px"
  47. :form-data="formData"
  48. :form-items="formItemsFeicTes"
  49. >
  50. </zj-form-module>
  51. </zj-form-container>
  52. </div>
  53. </zj-page-fill>
  54. <div v-if="activeName == 'goodsInfo'" style="text-align: right; box-sizing: border-box; padding: 16px 20px">
  55. <el-button v-if="formDialogType == 0" size="mini" type="primary" @click="save">保存</el-button>
  56. <el-button v-if="formDialogType == 1" size="mini" type="primary" @click="submit">提交</el-button>
  57. <el-button v-if="formDialogType == 3" size="mini" type="primary" @click="examine('OK')">审核通过</el-button>
  58. <el-button v-if="formDialogType == 3" size="mini" type="primary" @click="examine('FAIL')"
  59. >审核驳回</el-button
  60. >
  61. </div>
  62. </zj-page-container>
  63. </el-dialog>
  64. </div>
  65. <el-dialog title="计划单明细" :visible.sync="dialogVisible" width="1000px" :before-close="handleCloseTes">
  66. <div style="width: 960px; height: 680px">
  67. <template-page
  68. v-if="dialogVisible"
  69. ref="pageRefTes"
  70. :get-list="getListTes"
  71. :table-attributes="tableAttributesTes"
  72. :table-events="tableEventsTes"
  73. >
  74. </template-page>
  75. </div>
  76. <span slot="footer" class="dialog-footer">
  77. <el-button @click="dialogVisible = false">取 消</el-button>
  78. <el-button type="primary" @click="quedingtianjia">确 定</el-button>
  79. </span>
  80. </el-dialog>
  81. </template-page>
  82. </template>
  83. <script>
  84. import TemplatePage from '@/components/template/template-page-1.vue'
  85. import import_mixin from '@/components/template/import_mixin.js'
  86. import operation_mixin from '@/components/template/operation_mixin.js'
  87. import {
  88. goodsPurchaseList,
  89. goodsPurchaseListExport,
  90. goodsPurchaseItemList,
  91. goodsPurchaseItemListExport,
  92. goodsPurchaseCodeList,
  93. goodsPurchaseCodeListExport,
  94. goodsPurchaseAdd,
  95. goodsPurchaseDetail,
  96. goodsPurchaseSubmit,
  97. goodsPurchaseConfirm,
  98. goodsPurchaseDel
  99. } from '@/api/goodsPurchasedStored.js'
  100. import { goodsPlanItemList } from '@/api/purchaseSchedule.js'
  101. import form_ty from '../mixins/common_form'
  102. import storage_table from '../mixins/storage_table'
  103. import storage_goods from '../mixins/storage_goods'
  104. import storage_codes from '../mixins/storage_codes'
  105. import common from '../mixins/common_code'
  106. import jihuamingxi from '../mixins/jihuamingxi'
  107. import { delayPerform, firstPerform, intervalPerform, passivePerform, queuePerform } from 'js-perform-lock'
  108. import { required, diyRequired } from '@/components/template/rules_verify.js'
  109. export default {
  110. components: { TemplatePage },
  111. mixins: [import_mixin, operation_mixin, form_ty, storage_table, storage_goods, storage_codes, common, jihuamingxi],
  112. data() {
  113. return {
  114. dialogVisible: false,
  115. pageType: 'list',
  116. pageShow: true,
  117. // 表格属性
  118. tableAttributes: {
  119. // 启用勾选列
  120. selectColumn: false
  121. },
  122. tableAttributesTes: {
  123. // 启用勾选列
  124. selectColumn: true,
  125. reserveSelection: true,
  126. 'row-key': 'goodsPlanItemId'
  127. },
  128. tableEventsTes: {
  129. 'selection-change': this.selectionChangeTes
  130. },
  131. // 表格事件
  132. tableEvents: {
  133. 'selection-change': this.selectionChange
  134. },
  135. // 勾选选中行
  136. recordSelected: [],
  137. /** 表单变量 */
  138. formDialogType: 0,
  139. formDialogTitles: ['新增入库单', '编辑入库单', '入库单详情', '审核入库单'],
  140. formDialog: false,
  141. appraise_status: '',
  142. formData: {
  143. companyWechatId: '',
  144. companyWechatName: '',
  145. examineBy: '',
  146. examineTime: '',
  147. fileUrl: '',
  148. remark: '',
  149. status: '',
  150. submitBy: '',
  151. submitTime: '',
  152. totalAmount: 0,
  153. totalQty: 0,
  154. updateBy: '',
  155. updateTime: '',
  156. venderId: '',
  157. venderName: '',
  158. storageId: '',
  159. storageName: '',
  160. fileUrl: [],
  161. items: [],
  162. planItems: [],
  163. codeInfoList: [],
  164. isPlan: ''
  165. },
  166. activeName: 'goodsInfo',
  167. goods_material_id: '',
  168. joinCode: false,
  169. joinCodeText: JSON.parse(localStorage.getItem('greemall_user')).joinCode,
  170. logs: [],
  171. tesXuanXiang: []
  172. }
  173. },
  174. computed: {
  175. // 事件组合
  176. optionsEvensGroup() {
  177. if (this.pageType == 'list') {
  178. return [
  179. [
  180. [
  181. this.optionsEvensAuth('add', {
  182. click: () => {
  183. this.openForm()
  184. this.formDialog = true
  185. this.joinCode = JSON.parse(localStorage.getItem('greemall_user')).joinCode === 'CODE'
  186. }
  187. })
  188. ]
  189. ]
  190. ]
  191. } else if (this.pageType == 'goodsder') {
  192. return []
  193. } else if (this.pageType == 'codeder') {
  194. return []
  195. }
  196. },
  197. // 更多参数
  198. moreParameters() {
  199. return []
  200. },
  201. formItemsFeicTes() {
  202. return [
  203. {
  204. md: 24,
  205. isShow: true,
  206. name: 'slot-component',
  207. formItemAttributes: {
  208. label: '',
  209. prop: 'planItems',
  210. 'label-width': '0px',
  211. rules: this.formData.isPlan ? [...required] : []
  212. },
  213. render: (h, { props, onInput }) => {
  214. var { value } = props
  215. return (
  216. <div>
  217. {[
  218. !!~[0, 1].indexOf(this.formDialogType) ? (
  219. <div style="margin-bottom:10px">
  220. <el-button
  221. type="primary"
  222. onClick={() => {
  223. if (this.formData.venderId) {
  224. this.dialogVisible = true
  225. this.tesXuanXiang = []
  226. } else {
  227. this.$message({
  228. dangerouslyUseHTMLString: true,
  229. type: 'warning',
  230. message: '请选择供应商',
  231. duration: 5000
  232. })
  233. }
  234. }}
  235. >
  236. 添加
  237. </el-button>
  238. </div>
  239. ) : null,
  240. <zj-table
  241. columns={this.teshumingxi}
  242. tableData={this.formData.planItems}
  243. tableAttributes={{
  244. size: 'mini',
  245. border: true
  246. }}
  247. />
  248. ]}
  249. </div>
  250. )
  251. }
  252. }
  253. ]
  254. }
  255. },
  256. watch: {
  257. pageType() {
  258. this.handleClose()
  259. this.pageShow = false
  260. this.$nextTick(() => {
  261. this.pageShow = true
  262. })
  263. },
  264. 'formData.venderId'() {
  265. this.formData.planItems = []
  266. }
  267. },
  268. methods: {
  269. tishicuowu: new delayPerform(500).refactor(function (/**可接收参数**/) {
  270. if (this.logs) {
  271. var logs = Array.from(
  272. new Set(
  273. JSON.parse(JSON.stringify(this.logs)).map(item => {
  274. return `${item.index !== undefined ? '第' + (item.index + 1) + '行:' : ''}${item.errMsg}`
  275. })
  276. )
  277. )
  278. this.logs = []
  279. this.$message({
  280. dangerouslyUseHTMLString: true,
  281. type: 'warning',
  282. message: logs.join('<div/>'),
  283. duration: 5000
  284. })
  285. }
  286. }),
  287. getListTes(p, cb) {
  288. return goodsPlanItemList({
  289. ...p,
  290. params: [
  291. ...p.params,
  292. { param: 'a.vender_id', compare: '=', value: this.formData.venderId },
  293. { param: 'b.surplus_qty', compare: '>', value: '0' }
  294. ]
  295. })
  296. },
  297. handleCloseTes() {
  298. this.dialogVisible = false
  299. },
  300. selectionChangeTes(data) {
  301. this.tesXuanXiang = data
  302. },
  303. quedingtianjia() {
  304. this.tesXuanXiang.map(item => {
  305. if (!this.formData.planItems.find(v => v.goodsPlanItemId == item.goodsPlanItemId)) {
  306. this.formData.planItems.unshift({
  307. amount: '', //
  308. brandId: item.brandId,
  309. brandName: item.brandName,
  310. enginCode: item.enginCode,
  311. enginName: item.enginName,
  312. factoryNo: item.factoryNo,
  313. goodsMaterialId: item.goodsMaterialId,
  314. goodsMaterialName: item.goodsMaterialName,
  315. goodsPlanId: item.id,
  316. goodsPlanItemId: item.goodsPlanItemId,
  317. goodsPurchaseId: '', //
  318. goodsPurchasePlanItemId: '', //
  319. inStockQty: item.inStockQty,
  320. insideQty: '', //
  321. mainId: item.mainId,
  322. mainName: item.mainName,
  323. orderGoodsType: item.orderGoodsType,
  324. qty: item.qty,
  325. outQty: '', //
  326. partsQty: '', //
  327. price: '', //
  328. recQty: '', //
  329. retQty: '', //
  330. seriesName: item.seriesName,
  331. smallId: item.smallId,
  332. smallName: item.smallName,
  333. specsName: item.specsName,
  334. surplusQty: item.surplusQty,
  335. unit: item.unit
  336. })
  337. }
  338. })
  339. this.dialogVisible = false
  340. },
  341. changePageType() {
  342. this.goods_material_id = ''
  343. },
  344. // 列表请求函数
  345. getList(p, cb) {
  346. if (this.pageType == 'list') {
  347. return goodsPurchaseList(p)
  348. } else if (this.pageType == 'goodsder') {
  349. return goodsPurchaseItemList(p)
  350. } else if (this.pageType == 'codeder') {
  351. if (this.goods_material_id) {
  352. return goodsPurchaseCodeList({
  353. ...p,
  354. params: [...p.params, { param: 'b.goods_material_id', compare: '=', value: this.goods_material_id }]
  355. })
  356. } else {
  357. return goodsPurchaseCodeList(p)
  358. }
  359. }
  360. },
  361. // 列表导出函数
  362. exportList(...p) {
  363. if (this.pageType == 'list') {
  364. return goodsPurchaseListExport(...p)
  365. } else if (this.pageType == 'goodsder') {
  366. return goodsPurchaseItemListExport(...p)
  367. } else if (this.pageType == 'codeder') {
  368. return goodsPurchaseCodeListExport(...p)
  369. }
  370. },
  371. // 表格列解析渲染数据更改
  372. columnParsing(item, defaultData) {
  373. return defaultData
  374. },
  375. // 监听勾选变化
  376. selectionChange(data) {
  377. this.recordSelected = data
  378. },
  379. // 打开创建弹窗
  380. openForm() {
  381. this.isEditIndex = -1
  382. this.getGysList()
  383. this.getWarehouseList()
  384. this.getBaseList()
  385. },
  386. // 打开详情弹窗
  387. openDetailForm(row, type) {
  388. goodsPurchaseDetail({ id: row.id }).then(res => {
  389. Object.assign(this.formData, res.data, {
  390. fileUrl: res.data.fileUrl ? [{ url: res.data.fileUrl }] : [],
  391. items: res.data.items.map(item => ({ ...item, details: {} }))
  392. })
  393. this.joinCode = res.data.joinCode === 'CODE'
  394. this.formDialogType = type
  395. this.openForm()
  396. this.formDialog = true
  397. })
  398. },
  399. // 关闭弹窗
  400. handleClose() {
  401. this.$refs?.formRef?.resetFields()
  402. this.formData = this.$options?.data()?.formData
  403. this.formDialog = false
  404. this.formDialogType = 0
  405. this.activeName = 'goodsInfo'
  406. this.joinCode = false
  407. },
  408. // 操作按钮
  409. operation() {
  410. if (this.pageType == 'list') {
  411. return this.operationBtn({
  412. edit: {
  413. conditions: ({ row, index, column }) => {
  414. return row.status == 'SAVE'
  415. },
  416. click: ({ row, index, column }) => {
  417. this.openDetailForm(row, 1)
  418. }
  419. },
  420. del: {
  421. prompt: '是否确定删除',
  422. conditions: ({ row, index, column }) => {
  423. return row.status == 'SAVE'
  424. },
  425. click: ({ row, index, column }) => {
  426. goodsPurchaseDel({
  427. id: row.id
  428. }).then(res => {
  429. this.$message({
  430. type: 'success',
  431. message: '删除成功'
  432. })
  433. this.$refs.pageRef.refreshList()
  434. })
  435. }
  436. },
  437. detail: {
  438. click: ({ row, index, column }) => {
  439. this.openDetailForm(row, 2)
  440. }
  441. },
  442. shenhe: {
  443. conditions: ({ row, index, column }) => {
  444. return row.status == 'WAIT'
  445. },
  446. click: ({ row, index, column }) => {
  447. this.openDetailForm(row, 3)
  448. }
  449. }
  450. })
  451. } else if (this.pageType == 'goodsder') {
  452. return this.operationBtn({
  453. codeDetail: {
  454. click: ({ row, index, column }) => {
  455. this.goods_material_id = row.goodsMaterialId
  456. this.pageType = 'codeder'
  457. }
  458. }
  459. })
  460. } else if (this.pageType == 'codeder') {
  461. return undefined
  462. }
  463. },
  464. // 保存
  465. save() {
  466. this.$refs.formRef.validateField(this.getVfyKey(this.isEditIndex), (valid, invalidFields, errLabels) => {
  467. if (valid && this.eidtItems()) {
  468. if (!this.formData.storageId && JSON.parse(localStorage.getItem('greemall_user')).joinCode != 'NO') {
  469. return this.$message({
  470. type: 'warning',
  471. message: '仓库不能为空'
  472. })
  473. }
  474. if (this.formData.isPlan) {
  475. try {
  476. this.formData.planItems.map((item, index) => {
  477. if (!item.recQty || item.recQty == 0) {
  478. throw new Error('')
  479. }
  480. })
  481. } catch (error) {
  482. this.$message.warning('到货数量必须填写并且大于0')
  483. return false
  484. }
  485. }
  486. goodsPurchaseAdd({
  487. ...this.formData,
  488. items: this.formData.items.map((item, index) => ({ ...item, index: index + 1 })),
  489. fileUrl: this.formData.fileUrl.map(item => item.url).join(','),
  490. codeInfoList: undefined
  491. }).then(res => {
  492. this.$message({
  493. type: 'success',
  494. message: '保存成功'
  495. })
  496. this.$refs.pageRef.refreshList()
  497. this.handleClose()
  498. })
  499. }
  500. })
  501. },
  502. // 提交
  503. submit() {
  504. goodsPurchaseSubmit({
  505. id: this.formData.id
  506. }).then(res => {
  507. this.$message({
  508. type: 'success',
  509. message: '提交成功'
  510. })
  511. this.handleClose()
  512. this.$refs.pageRef.refreshList()
  513. })
  514. },
  515. // 审核
  516. examine(type) {
  517. goodsPurchaseConfirm({
  518. id: this.formData.id,
  519. statusEnum: type
  520. }).then(res => {
  521. this.$message({
  522. type: 'success',
  523. message: '操作成功'
  524. })
  525. this.handleClose()
  526. this.$refs.pageRef.refreshList()
  527. })
  528. }
  529. }
  530. }
  531. </script>
  532. <style lang="scss" scoped>
  533. .tab {
  534. padding: 20px 20px 0 20px;
  535. }
  536. ::v-deep .teshudeshangchuananniu {
  537. color: #409eff !important;
  538. }
  539. </style>