PurchaseBackModal.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. <template>
  2. <j-modal
  3. :title="title"
  4. :width="width"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. :keyboard="false"
  8. :forceRender="true"
  9. v-bind:prefixNo="prefixNo"
  10. fullscreen
  11. switchFullscreen
  12. @cancel="handleCancel"
  13. :id="prefixNo"
  14. style="top: 20px; height: 95%"
  15. >
  16. <template slot="footer">
  17. <a-button @click="handleCancel">取消</a-button>
  18. <a-button v-if="billPrintFlag && isShowPrintBtn" @click="handlePrint('采购退货出库')">三联打印预览</a-button>
  19. <a-button v-if="checkFlag && isCanCheck" :loading="confirmLoading" @click="handleOkAndCheck">保存并审核</a-button>
  20. <a-button type="primary" :loading="confirmLoading" @click="handleOk">保存(Ctrl+S)</a-button>
  21. <!--发起多级审核-->
  22. <a-button v-if="!checkFlag" @click="handleWorkflow()" type="primary">提交流程</a-button>
  23. </template>
  24. <a-spin :spinning="confirmLoading">
  25. <a-form :form="form">
  26. <a-row class="form-row" :gutter="24">
  27. <a-col :lg="6" :md="12" :sm="24">
  28. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="供应商">
  29. <a-select
  30. placeholder="请选择供应商"
  31. v-decorator="['organId', validatorRules.organId]"
  32. :disabled="!rowCanEdit"
  33. :dropdownMatchSelectWidth="false"
  34. showSearch
  35. optionFilterProp="children"
  36. >
  37. <div slot="dropdownRender" slot-scope="menu">
  38. <v-nodes :vnodes="menu" />
  39. <a-divider style="margin: 4px 0" />
  40. <div
  41. v-if="quickBtn.vendor"
  42. style="padding: 4px 8px; cursor: pointer"
  43. @mousedown="(e) => e.preventDefault()"
  44. @click="addSupplier"
  45. >
  46. <a-icon type="plus" /> 新增供应商
  47. </div>
  48. </div>
  49. <a-select-option v-for="(item, index) in supList" :key="index" :value="item.id">
  50. {{ item.supplier }}
  51. </a-select-option>
  52. </a-select>
  53. </a-form-item>
  54. </a-col>
  55. <a-col :lg="6" :md="12" :sm="24">
  56. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="单据日期">
  57. <j-date v-decorator="['operTime', validatorRules.operTime]" :show-time="true" />
  58. </a-form-item>
  59. </a-col>
  60. <a-col :lg="6" :md="12" :sm="24">
  61. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="单据编号">
  62. <a-input placeholder="请输入单据编号" v-decorator.trim="['number']" />
  63. </a-form-item>
  64. </a-col>
  65. <a-col :lg="6" :md="12" :sm="24">
  66. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="关联单据">
  67. <a-input-search
  68. placeholder="请选择关联单据"
  69. v-decorator="['linkNumber']"
  70. @search="onSearchLinkNumber"
  71. :readOnly="true"
  72. />
  73. </a-form-item>
  74. </a-col>
  75. </a-row>
  76. <j-editable-table
  77. id="billModal"
  78. :ref="refKeys[0]"
  79. :loading="materialTable.loading"
  80. :columns="materialTable.columns"
  81. :dataSource="materialTable.dataSource"
  82. :minWidth="minWidth"
  83. :maxHeight="300"
  84. :rowNumber="false"
  85. :rowSelection="rowCanEdit"
  86. :actionButton="rowCanEdit"
  87. :dragSortAndNumber="rowCanEdit"
  88. @valueChange="onValueChange"
  89. @added="onAdded"
  90. @deleted="onDeleted"
  91. >
  92. <template #buttonAfter>
  93. <a-row
  94. v-if="rowCanEdit"
  95. :gutter="24"
  96. style="float: left; padding-bottom: 5px"
  97. data-step="4"
  98. data-title="扫码录入"
  99. data-intro="此功能支持扫码枪扫描SKU进行录入"
  100. >
  101. <a-col v-if="scanStatus" :md="6" :sm="24">
  102. <a-button @click="scanEnter" style="margin-right: 8px">扫码录入</a-button>
  103. </a-col>
  104. <a-col v-if="!scanStatus" :md="16" :sm="24" style="padding: 0 6px 0 12px">
  105. <a-input
  106. placeholder="请扫条码或序列号并回车"
  107. v-model="scanBarCode"
  108. @pressEnter="scanPressEnter"
  109. ref="scanBarCode"
  110. />
  111. </a-col>
  112. <a-col v-if="!scanStatus" :md="6" :sm="24" style="padding: 0px 12px 0 0">
  113. <a-button @click="stopScan" style="margin-right: 8px">收起扫码</a-button>
  114. </a-col>
  115. </a-row>
  116. </template>
  117. <template #depotBatchSet>
  118. <a-icon type="down" @click="handleBatchSetDepot" />
  119. </template>
  120. <template #depotAdd>
  121. <a-divider v-if="quickBtn.depot" style="margin: 4px 0" />
  122. <div v-if="quickBtn.depot" style="padding: 4px 8px; cursor: pointer" @click="addDepot">
  123. <a-icon type="plus" /> 新增仓库
  124. </div>
  125. </template>
  126. </j-editable-table>
  127. <a-row class="form-row" :gutter="24">
  128. <a-col :lg="24" :md="24" :sm="24">
  129. <a-form-item :labelCol="labelCol" :wrapperCol="{ xs: { span: 24 }, sm: { span: 24 } }" label="">
  130. <a-textarea :rows="1" placeholder="请输入备注" v-decorator="['remark']" style="margin-top: 8px" />
  131. </a-form-item>
  132. </a-col>
  133. </a-row>
  134. <a-row class="form-row" :gutter="24">
  135. <a-col :lg="6" :md="12" :sm="24">
  136. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="优惠率">
  137. <a-input
  138. style="width: 80%"
  139. placeholder="请输入优惠率"
  140. v-decorator.trim="['discount']"
  141. suffix="%"
  142. @change="onChangeDiscount"
  143. />
  144. </a-form-item>
  145. </a-col>
  146. <a-col :lg="6" :md="12" :sm="24">
  147. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="退款优惠">
  148. <a-input
  149. placeholder="请输入付款优惠"
  150. v-decorator.trim="['discountMoney']"
  151. @change="onChangeDiscountMoney"
  152. />
  153. </a-form-item>
  154. </a-col>
  155. <a-col :lg="6" :md="12" :sm="24">
  156. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="优惠后金额">
  157. <a-input placeholder="请输入优惠后金额" v-decorator.trim="['discountLastMoney']" :readOnly="true" />
  158. </a-form-item>
  159. </a-col>
  160. <a-col :lg="6" :md="12" :sm="24">
  161. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="其它费用">
  162. <a-input placeholder="请输入其它费用" v-decorator.trim="['otherMoney']" @change="onChangeOtherMoney" />
  163. </a-form-item>
  164. </a-col>
  165. </a-row>
  166. <a-row class="form-row" :gutter="24">
  167. <a-col :lg="6" :md="12" :sm="24">
  168. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="结算账户">
  169. <a-select
  170. style="width: 80%"
  171. placeholder="请选择结算账户"
  172. v-decorator="['accountId', validatorRules.accountId]"
  173. :dropdownMatchSelectWidth="false"
  174. allowClear
  175. @select="selectAccount"
  176. >
  177. <div slot="dropdownRender" slot-scope="menu">
  178. <v-nodes :vnodes="menu" />
  179. <a-divider style="margin: 4px 0" />
  180. <div
  181. v-if="quickBtn.account"
  182. style="padding: 4px 8px; cursor: pointer"
  183. @mousedown="(e) => e.preventDefault()"
  184. @click="addAccount"
  185. >
  186. <a-icon type="plus" /> 新增结算账户
  187. </div>
  188. </div>
  189. <a-select-option v-for="(item, index) in accountList" :key="index" :value="item.id">
  190. {{ item.name }}
  191. </a-select-option>
  192. </a-select>
  193. <a-tooltip title="多账户明细">
  194. <a-button
  195. type="default"
  196. icon="folder"
  197. style="margin-left: 8px"
  198. size="small"
  199. v-show="manyAccountBtnStatus"
  200. @click="handleManyAccount"
  201. />
  202. </a-tooltip>
  203. </a-form-item>
  204. </a-col>
  205. <a-col :lg="6" :md="12" :sm="24">
  206. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="本次退款">
  207. <a-input
  208. placeholder="请输入本次退款"
  209. v-decorator.trim="['changeAmount']"
  210. @change="onChangeChangeAmount"
  211. />
  212. </a-form-item>
  213. </a-col>
  214. <a-col :lg="6" :md="12" :sm="24">
  215. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="本次欠款">
  216. <a-input placeholder="请输入本次欠款" v-decorator.trim="['debt']" :readOnly="true" />
  217. </a-form-item>
  218. </a-col>
  219. <a-col :lg="6" :md="12" :sm="24"> </a-col>
  220. </a-row>
  221. <a-row class="form-row" :gutter="24">
  222. <a-col :lg="6" :md="12" :sm="24">
  223. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="附件">
  224. <j-upload v-model="fileList" bizPath="bill"></j-upload>
  225. </a-form-item>
  226. </a-col>
  227. </a-row>
  228. </a-form>
  229. </a-spin>
  230. <many-account-modal ref="manyAccountModalForm" @ok="manyAccountModalFormOk"></many-account-modal>
  231. <link-bill-list ref="linkBillList" @ok="linkBillListOk"></link-bill-list>
  232. <vendor-modal ref="vendorModalForm" @ok="vendorModalFormOk"></vendor-modal>
  233. <depot-modal ref="depotModalForm" @ok="depotModalFormOk"></depot-modal>
  234. <account-modal ref="accountModalForm" @ok="accountModalFormOk"></account-modal>
  235. <batch-set-depot ref="batchSetDepotModalForm" @ok="batchSetDepotModalFormOk"></batch-set-depot>
  236. <workflow-iframe ref="modalWorkflow" @ok="workflowModalFormOk"></workflow-iframe>
  237. <bill-print-iframe ref="modalPrint"></bill-print-iframe>
  238. </j-modal>
  239. </template>
  240. <script>
  241. import pick from 'lodash.pick'
  242. import ManyAccountModal from '../dialog/ManyAccountModal'
  243. import LinkBillList from '../dialog/LinkBillList'
  244. import VendorModal from '../../system/modules/VendorModal'
  245. import DepotModal from '../../system/modules/DepotModal'
  246. import AccountModal from '../../system/modules/AccountModal'
  247. import BatchSetDepot from '../dialog/BatchSetDepot'
  248. import WorkflowIframe from '@/components/tools/WorkflowIframe'
  249. import BillPrintIframe from '../dialog/BillPrintIframe'
  250. import { FormTypes } from '@/utils/JEditableTableUtil'
  251. import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
  252. import { BillModalMixin } from '../mixins/BillModalMixin'
  253. import { getMpListShort } from '@/utils/util'
  254. import { getAction } from '@/api/manage'
  255. import JUpload from '@/components/jeecg/JUpload'
  256. import JDate from '@/components/jeecg/JDate'
  257. import Vue from 'vue'
  258. export default {
  259. name: 'PurchaseBackModal',
  260. mixins: [JEditableTableMixin, BillModalMixin],
  261. components: {
  262. ManyAccountModal,
  263. LinkBillList,
  264. VendorModal,
  265. DepotModal,
  266. AccountModal,
  267. BatchSetDepot,
  268. WorkflowIframe,
  269. BillPrintIframe,
  270. JUpload,
  271. JDate,
  272. VNodes: {
  273. functional: true,
  274. render: (h, ctx) => ctx.props.vnodes,
  275. },
  276. },
  277. data() {
  278. return {
  279. title: '操作',
  280. width: '1600px',
  281. moreStatus: false,
  282. // 新增时子表默认添加几行空数据
  283. addDefaultRowNum: 1,
  284. visible: false,
  285. operTimeStr: '',
  286. prefixNo: 'CGTH',
  287. fileList: [],
  288. rowCanEdit: true,
  289. model: {},
  290. labelCol: {
  291. xs: { span: 24 },
  292. sm: { span: 8 },
  293. },
  294. wrapperCol: {
  295. xs: { span: 24 },
  296. sm: { span: 16 },
  297. },
  298. refKeys: ['materialDataTable'],
  299. activeKey: 'materialDataTable',
  300. materialTable: {
  301. loading: false,
  302. dataSource: [],
  303. columns: [
  304. {
  305. title: '仓库名称',
  306. key: 'depotId',
  307. width: '8%',
  308. type: FormTypes.select,
  309. placeholder: '请选择${title}',
  310. options: [],
  311. allowSearch: true,
  312. validateRules: [{ required: true, message: '${title}不能为空' }],
  313. },
  314. {
  315. title: '条码',
  316. key: 'barCode',
  317. width: '12%',
  318. type: FormTypes.popupJsh,
  319. kind: 'material',
  320. multi: true,
  321. validateRules: [{ required: true, message: '${title}不能为空' }],
  322. },
  323. { title: '名称', key: 'name', width: '10%', type: FormTypes.normal },
  324. { title: '规格', key: 'standard', width: '9%', type: FormTypes.normal },
  325. { title: '型号', key: 'model', width: '9%', type: FormTypes.normal },
  326. { title: '颜色', key: 'color', width: '5%', type: FormTypes.normal },
  327. { title: '品牌', key: 'brand', width: '6%', type: FormTypes.normal },
  328. { title: '制造商', key: 'mfrs', width: '6%', type: FormTypes.normal },
  329. { title: '扩展信息', key: 'materialOther', width: '5%', type: FormTypes.normal },
  330. { title: '库存', key: 'stock', width: '5%', type: FormTypes.normal },
  331. { title: '单位', key: 'unit', width: '4%', type: FormTypes.normal },
  332. { title: '序列号', key: 'snList', width: '12%', type: FormTypes.popupJsh, kind: 'sn', multi: true },
  333. { title: '批号', key: 'batchNumber', width: '7%', type: FormTypes.popupJsh, kind: 'batch', multi: false },
  334. { title: '有效期', key: 'expirationDate', width: '7%', type: FormTypes.input, readonly: true },
  335. { title: '多属性', key: 'sku', width: '9%', type: FormTypes.normal },
  336. { title: '原数量', key: 'preNumber', width: '5%', type: FormTypes.normal },
  337. { title: '已退货', key: 'finishNumber', width: '5%', type: FormTypes.normal },
  338. {
  339. title: '数量',
  340. key: 'operNumber',
  341. width: '5%',
  342. type: FormTypes.inputNumber,
  343. statistics: true,
  344. validateRules: [{ required: true, message: '${title}不能为空' }],
  345. },
  346. { title: '单价', key: 'unitPrice', width: '5%', type: FormTypes.inputNumber },
  347. { title: '金额', key: 'allPrice', width: '5%', type: FormTypes.inputNumber, statistics: true },
  348. { title: '税率', key: 'taxRate', width: '4%', type: FormTypes.inputNumber, placeholder: '%' },
  349. {
  350. title: '税额',
  351. key: 'taxMoney',
  352. width: '5%',
  353. type: FormTypes.inputNumber,
  354. readonly: true,
  355. statistics: true,
  356. },
  357. { title: '价税合计', key: 'taxLastMoney', width: '7%', type: FormTypes.inputNumber, statistics: true },
  358. { title: '备注', key: 'remark', width: '6%', type: FormTypes.input },
  359. { title: '关联id', key: 'linkId', width: '5%', type: FormTypes.hidden },
  360. { title: '是否再次编辑', key: 'isEdit', width: '5%', type: FormTypes.hidden },
  361. ],
  362. },
  363. confirmLoading: false,
  364. validatorRules: {
  365. operTime: {
  366. rules: [{ required: true, message: '请输入单据日期!' }],
  367. },
  368. organId: {
  369. rules: [{ required: true, message: '请选择供应商!' }],
  370. },
  371. accountId: {
  372. rules: [{ required: true, message: '请选择结算账户!' }],
  373. },
  374. },
  375. url: {
  376. add: '/depotHead/addDepotHeadAndDetail',
  377. edit: '/depotHead/updateDepotHeadAndDetail',
  378. detailList: '/depotItem/getDetailList',
  379. },
  380. }
  381. },
  382. created() {},
  383. methods: {
  384. //调用完edit()方法之后会自动调用此方法
  385. editAfter() {
  386. this.billStatus = '0'
  387. this.rowCanEdit = true
  388. this.materialTable.columns[1].type = FormTypes.popupJsh
  389. this.changeColumnHide()
  390. this.changeFormTypes(this.materialTable.columns, 'snList', 0)
  391. this.changeFormTypes(this.materialTable.columns, 'batchNumber', 0)
  392. this.changeFormTypes(this.materialTable.columns, 'expirationDate', 0)
  393. this.changeFormTypes(this.materialTable.columns, 'preNumber', 0)
  394. this.changeFormTypes(this.materialTable.columns, 'finishNumber', 0)
  395. if (this.action === 'add') {
  396. this.addInit(this.prefixNo)
  397. this.fileList = []
  398. } else {
  399. if (this.model.linkNumber) {
  400. this.rowCanEdit = false
  401. this.materialTable.columns[1].type = FormTypes.normal
  402. }
  403. this.model.operTime = this.model.operTimeStr
  404. this.model.debt = (this.model.discountLastMoney + this.model.otherMoney - this.model.changeAmount).toFixed(2)
  405. if (this.model.accountId == null) {
  406. this.model.accountId = 0
  407. this.manyAccountBtnStatus = true
  408. this.accountIdList = this.model.accountIdList
  409. this.accountMoneyList = this.model.accountMoneyList
  410. } else {
  411. this.manyAccountBtnStatus = false
  412. }
  413. this.fileList = this.model.fileName
  414. this.$nextTick(() => {
  415. this.form.setFieldsValue(
  416. pick(
  417. this.model,
  418. 'organId',
  419. 'operTime',
  420. 'number',
  421. 'linkNumber',
  422. 'remark',
  423. 'discount',
  424. 'discountMoney',
  425. 'discountLastMoney',
  426. 'otherMoney',
  427. 'accountId',
  428. 'changeAmount',
  429. 'debt'
  430. )
  431. )
  432. })
  433. // 加载子表数据
  434. let params = {
  435. headerId: this.model.id,
  436. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  437. linkType: 'basic',
  438. }
  439. let url = this.readOnly ? this.url.detailList : this.url.detailList
  440. this.requestSubTableData(url, params, this.materialTable)
  441. }
  442. //复制新增单据-初始化单号和日期
  443. if (this.action === 'copyAdd') {
  444. this.model.id = ''
  445. this.model.tenantId = ''
  446. this.copyAddInit(this.prefixNo)
  447. }
  448. this.initSystemConfig()
  449. this.initSupplier(0)
  450. this.initDepot()
  451. this.initAccount(0)
  452. this.initPlatform()
  453. this.initQuickBtn()
  454. },
  455. //提交单据时整理成formData
  456. classifyIntoFormData(allValues) {
  457. let totalPrice = 0
  458. let billMain = Object.assign(this.model, allValues.formValue)
  459. let detailArr = allValues.tablesValue[0].values
  460. billMain.type = '出库'
  461. billMain.subType = '采购退货'
  462. for (let item of detailArr) {
  463. totalPrice += item.allPrice - 0
  464. }
  465. billMain.totalPrice = totalPrice
  466. if (billMain.accountId === 0) {
  467. billMain.accountId = ''
  468. }
  469. billMain.accountIdList = this.accountIdList.length > 0 ? JSON.stringify(this.accountIdList) : ''
  470. billMain.accountMoneyList = this.accountMoneyList.length > 0 ? JSON.stringify(this.accountMoneyList) : ''
  471. if (this.fileList && this.fileList.length > 0) {
  472. billMain.fileName = this.fileList
  473. } else {
  474. billMain.fileName = ''
  475. }
  476. if (this.model.id) {
  477. billMain.id = this.model.id
  478. }
  479. billMain.status = this.billStatus
  480. return {
  481. info: JSON.stringify(billMain),
  482. rows: JSON.stringify(detailArr),
  483. }
  484. },
  485. onSearchLinkNumber() {
  486. this.$refs.linkBillList.show('入库', '采购', '供应商', '1,2,3')
  487. this.$refs.linkBillList.title = '请选择采购入库'
  488. },
  489. linkBillListOk(selectBillDetailRows, linkNumber, organId, discountMoney, deposit, remark, depotId, accountId) {
  490. this.rowCanEdit = false
  491. this.materialTable.columns[1].type = FormTypes.normal
  492. this.changeFormTypes(this.materialTable.columns, 'preNumber', 1)
  493. this.changeFormTypes(this.materialTable.columns, 'finishNumber', 1)
  494. if (selectBillDetailRows && selectBillDetailRows.length > 0) {
  495. let listEx = []
  496. let allTaxLastMoney = 0
  497. for (let j = 0; j < selectBillDetailRows.length; j++) {
  498. let info = selectBillDetailRows[j]
  499. if (info.finishNumber > 0) {
  500. info.operNumber = info.preNumber - info.finishNumber
  501. info.allPrice = info.operNumber * info.unitPrice - 0
  502. let taxRate = info.taxRate - 0
  503. info.taxMoney = ((info.allPrice * taxRate) / 100).toFixed(2) - 0
  504. info.taxLastMoney = (info.allPrice + info.taxMoney).toFixed(2) - 0
  505. }
  506. info.linkId = info.id
  507. allTaxLastMoney += info.taxLastMoney
  508. listEx.push(info)
  509. this.changeColumnShow(info)
  510. }
  511. this.materialTable.dataSource = listEx
  512. ///给优惠后金额重新赋值
  513. allTaxLastMoney = allTaxLastMoney ? allTaxLastMoney : 0
  514. let discount = 0
  515. if (allTaxLastMoney !== 0) {
  516. discount = ((discountMoney / allTaxLastMoney) * 100).toFixed(2) - 0
  517. }
  518. let discountLastMoney = (allTaxLastMoney - discountMoney).toFixed(2) - 0
  519. this.$nextTick(() => {
  520. this.form.setFieldsValue({
  521. organId: organId,
  522. linkNumber: linkNumber,
  523. discount: discount,
  524. discountMoney: discountMoney,
  525. discountLastMoney: discountLastMoney,
  526. changeAmount: discountLastMoney,
  527. accountId: accountId,
  528. remark: remark,
  529. })
  530. })
  531. }
  532. },
  533. },
  534. }
  535. </script>
  536. <style scoped></style>