PurchaseOrderModal.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  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. switchHelp
  12. switchFullscreen
  13. @cancel="handleCancel"
  14. :id="prefixNo"
  15. style="top: 20px; height: 95%"
  16. >
  17. <template slot="footer">
  18. <a-button @click="handleCancel">取消</a-button>
  19. <a-button v-if="billPrintFlag && isShowPrintBtn" @click="handlePrint('采购订单')">三联打印预览</a-button>
  20. <a-button v-if="checkFlag && isCanCheck" :loading="confirmLoading" @click="handleOkAndCheck">保存并审核</a-button>
  21. <a-button type="primary" :loading="confirmLoading" @click="handleOk">保存(Ctrl+S)</a-button>
  22. <!--发起多级审核-->
  23. <a-button v-if="!checkFlag" @click="handleWorkflow()" type="primary">提交流程</a-button>
  24. </template>
  25. <a-spin :spinning="confirmLoading">
  26. <a-form :form="form">
  27. <a-row class="form-row" :gutter="24">
  28. <a-col :lg="6" :md="12" :sm="24">
  29. <a-form-item
  30. :labelCol="labelCol"
  31. :wrapperCol="wrapperCol"
  32. label="供应商"
  33. data-step="1"
  34. data-title="供应商"
  35. data-intro="供应商必须选择,如果发现需要选择的供应商尚未录入,可以在下拉框中点击新增供应商进行录入"
  36. >
  37. <a-select
  38. placeholder="请选择供应商"
  39. v-decorator="['organId', validatorRules.organId]"
  40. :dropdownMatchSelectWidth="false"
  41. showSearch
  42. optionFilterProp="children"
  43. >
  44. <div slot="dropdownRender" slot-scope="menu">
  45. <v-nodes :vnodes="menu" />
  46. <a-divider style="margin: 4px 0" />
  47. <div
  48. v-if="quickBtn.vendor"
  49. style="padding: 4px 8px; cursor: pointer"
  50. @mousedown="(e) => e.preventDefault()"
  51. @click="addSupplier"
  52. >
  53. <a-icon type="plus" /> 新增供应商
  54. </div>
  55. </div>
  56. <a-select-option v-for="(item, index) in supList" :key="index" :value="item.id">
  57. {{ item.supplier }}
  58. </a-select-option>
  59. </a-select>
  60. </a-form-item>
  61. </a-col>
  62. <a-col :lg="6" :md="12" :sm="24">
  63. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="单据日期">
  64. <j-date v-decorator="['operTime', validatorRules.operTime]" :show-time="true" />
  65. </a-form-item>
  66. </a-col>
  67. <a-col :lg="6" :md="12" :sm="24">
  68. <a-form-item
  69. :labelCol="labelCol"
  70. :wrapperCol="wrapperCol"
  71. label="单据编号"
  72. data-step="2"
  73. data-title="单据编号"
  74. data-intro="单据编号自动生成、自动累加、开头是单据类型的首字母缩写,累加的规则是每次打开页面会自动占用一个新的编号"
  75. >
  76. <a-input placeholder="请输入单据编号" v-decorator.trim="['number']" />
  77. </a-form-item>
  78. </a-col>
  79. <a-col :lg="6" :md="12" :sm="24">
  80. <a-form-item
  81. :labelCol="labelCol"
  82. :wrapperCol="wrapperCol"
  83. label="关联请购单"
  84. data-step="3"
  85. data-title="关联请购单"
  86. data-intro="采购订单单据可以通过关联请购单来选择已录入的请购单,选择之后会自动加载请购单的内容,
  87. 提交之后原来的请购单会对应的改变单据状态。另外本系统支持分批多次关联"
  88. >
  89. <a-input-search
  90. placeholder="请选择关联请购单"
  91. v-decorator="['linkApply']"
  92. @search="onSearchLinkApply"
  93. :readOnly="true"
  94. />
  95. </a-form-item>
  96. </a-col>
  97. <a-col :lg="6" :md="12" :sm="24">
  98. <a-form-item
  99. v-if="purchaseBySaleFlag"
  100. :labelCol="labelCol"
  101. :wrapperCol="wrapperCol"
  102. label="关联订单"
  103. data-step="3"
  104. data-title="关联订单"
  105. data-intro="采购订单单据可以通过关联订单来选择已录入的销售订单,选择之后会自动加载订单的内容,
  106. 提交之后原来的销售订单会对应的改变单据状态。另外本系统支持分批多次关联"
  107. >
  108. <a-input-search
  109. placeholder="请选择关联销售订单"
  110. v-decorator="['linkNumber']"
  111. @search="onSearchLinkNumber"
  112. :readOnly="true"
  113. />
  114. </a-form-item>
  115. </a-col>
  116. </a-row>
  117. <j-editable-table
  118. id="billModal"
  119. :ref="refKeys[0]"
  120. :loading="materialTable.loading"
  121. :columns="materialTable.columns"
  122. :dataSource="materialTable.dataSource"
  123. :minWidth="minWidth"
  124. :maxHeight="300"
  125. :rowNumber="false"
  126. :rowSelection="rowCanEdit"
  127. :actionButton="rowCanEdit"
  128. :dragSortAndNumber="rowCanEdit"
  129. @valueChange="onValueChange"
  130. @added="onAdded"
  131. @deleted="onDeleted"
  132. @focusChange="getUnitInfo"
  133. >
  134. <template #buttonAfter>
  135. <a-row
  136. v-if="rowCanEdit"
  137. :gutter="24"
  138. style="float: left; padding-bottom: 5px"
  139. data-step="4"
  140. data-title="扫码录入"
  141. data-intro="此功能支持扫码枪扫描商品条码进行录入"
  142. >
  143. <a-col v-if="scanStatus" :md="6" :sm="24">
  144. <a-button @click="scanEnter">扫码录入</a-button>
  145. </a-col>
  146. <a-col v-if="!scanStatus" :md="16" :sm="24" style="padding: 0 8px 0 12px">
  147. <a-input
  148. placeholder="请扫描商品条码并回车"
  149. v-model="scanBarCode"
  150. @pressEnter="scanPressEnter"
  151. ref="scanBarCode"
  152. />
  153. </a-col>
  154. <a-col v-if="!scanStatus" :md="6" :sm="24" style="padding: 0px 12px 0 0">
  155. <a-button @click="stopScan">收起扫码</a-button>
  156. </a-col>
  157. </a-row>
  158. <a-row :gutter="24" style="float: left; padding-bottom: 5px">
  159. <a-col :md="24" :sm="24">
  160. <a-button style="margin-left: 8px" @click="handleHistoryBillList"
  161. ><a-icon type="history" />历史单据</a-button
  162. >
  163. </a-col>
  164. </a-row>
  165. <a-row v-if="rowCanEdit" :gutter="24" style="float: left; padding-bottom: 5px; padding-left: 20px">
  166. <a-button icon="import" @click="onImport(prefixNo)">导入明细</a-button>
  167. </a-row>
  168. </template>
  169. <template #unit="{ handleChange, handleFocus, value }">
  170. <a-select
  171. placeholder="请选择"
  172. v-decorator="['unit']"
  173. :dropdownMatchSelectWidth="false"
  174. showSearch
  175. :allowClear="false"
  176. optionFilterProp="children"
  177. :value="value"
  178. @change="($event) => handleChange($event)"
  179. @focus="($event) => handleFocus($event)"
  180. >
  181. <a-select-option v-for="(item, index) in unitList" :key="index" :value="item.name">
  182. {{ item.name }}
  183. </a-select-option>
  184. </a-select>
  185. </template>
  186. </j-editable-table>
  187. <a-row class="form-row" :gutter="24">
  188. <a-col :lg="24" :md="24" :sm="24">
  189. <a-form-item :labelCol="labelCol" :wrapperCol="{ xs: { span: 24 }, sm: { span: 24 } }" label="">
  190. <a-textarea :rows="1" placeholder="请输入备注" v-decorator="['remark']" style="margin-top: 8px" />
  191. </a-form-item>
  192. </a-col>
  193. </a-row>
  194. <a-row class="form-row" :gutter="24">
  195. <a-col :lg="6" :md="12" :sm="24">
  196. <a-form-item
  197. :labelCol="labelCol"
  198. :wrapperCol="wrapperCol"
  199. label="优惠率"
  200. data-step="5"
  201. data-title="优惠率"
  202. data-intro="针对单据明细中商品总金额进行优惠的比例"
  203. >
  204. <a-input
  205. style="width: 80%"
  206. placeholder="请输入优惠率"
  207. v-decorator.trim="['discount']"
  208. suffix="%"
  209. @change="onChangeDiscount"
  210. />
  211. </a-form-item>
  212. </a-col>
  213. <a-col :lg="6" :md="12" :sm="24">
  214. <a-form-item
  215. :labelCol="labelCol"
  216. :wrapperCol="wrapperCol"
  217. label="付款优惠"
  218. data-step="6"
  219. data-title="付款优惠"
  220. data-intro="针对单据明细中商品总金额进行优惠的金额"
  221. >
  222. <a-input
  223. placeholder="请输入付款优惠"
  224. v-decorator.trim="['discountMoney']"
  225. @change="onChangeDiscountMoney"
  226. />
  227. </a-form-item>
  228. </a-col>
  229. <a-col :lg="6" :md="12" :sm="24">
  230. <a-form-item
  231. :labelCol="labelCol"
  232. :wrapperCol="wrapperCol"
  233. label="优惠后金额"
  234. data-step="7"
  235. data-title="优惠后金额"
  236. data-intro="针对单据明细中商品总金额进行优惠后的金额"
  237. >
  238. <a-input placeholder="请输入优惠后金额" v-decorator.trim="['discountLastMoney']" :readOnly="true" />
  239. </a-form-item>
  240. </a-col>
  241. <a-col :lg="6" :md="12" :sm="24"></a-col>
  242. </a-row>
  243. <a-row class="form-row" :gutter="24">
  244. <a-col :lg="6" :md="12" :sm="24">
  245. <a-form-item
  246. :labelCol="labelCol"
  247. :wrapperCol="wrapperCol"
  248. label="结算账户"
  249. data-step="8"
  250. data-title="结算账户"
  251. data-intro="如果在下拉框中选择多账户,则可以通过多个结算账户进行结算"
  252. >
  253. <a-select
  254. style="width: 80%"
  255. placeholder="请选择结算账户"
  256. v-decorator="['accountId']"
  257. :dropdownMatchSelectWidth="false"
  258. allowClear
  259. @select="selectAccount"
  260. >
  261. <div slot="dropdownRender" slot-scope="menu">
  262. <v-nodes :vnodes="menu" />
  263. <a-divider style="margin: 4px 0" />
  264. <div
  265. v-if="quickBtn.account"
  266. style="padding: 4px 8px; cursor: pointer"
  267. @mousedown="(e) => e.preventDefault()"
  268. @click="addAccount"
  269. >
  270. <a-icon type="plus" /> 新增结算账户
  271. </div>
  272. </div>
  273. <a-select-option v-for="(item, index) in accountList" :key="index" :value="item.id">
  274. {{ item.name }}
  275. </a-select-option>
  276. </a-select>
  277. <a-tooltip title="多账户明细">
  278. <a-button
  279. type="default"
  280. icon="folder"
  281. style="margin-left: 8px"
  282. size="small"
  283. v-show="manyAccountBtnStatus"
  284. @click="handleManyAccount"
  285. />
  286. </a-tooltip>
  287. </a-form-item>
  288. </a-col>
  289. <a-col :lg="6" :md="12" :sm="24">
  290. <a-form-item
  291. :labelCol="labelCol"
  292. :wrapperCol="wrapperCol"
  293. label="支付订金"
  294. data-step="9"
  295. data-title="支付订金"
  296. data-intro="填写订金之后,在采购入库单会自动计算扣除订金"
  297. >
  298. <a-input
  299. placeholder="请输入支付订金"
  300. v-decorator.trim="['changeAmount', validatorRules.price]"
  301. @change="onChangeChangeAmount"
  302. />
  303. </a-form-item>
  304. </a-col>
  305. <a-col :lg="6" :md="12" :sm="24"> </a-col>
  306. <a-col :lg="6" :md="12" :sm="24"> </a-col>
  307. </a-row>
  308. <a-row class="form-row" :gutter="24">
  309. <a-col :lg="6" :md="12" :sm="24">
  310. <a-form-item
  311. :labelCol="labelCol"
  312. :wrapperCol="wrapperCol"
  313. label="附件"
  314. data-step="10"
  315. data-title="附件"
  316. data-intro="可以上传与单据相关的图片、文档,支持多个文件"
  317. >
  318. <j-upload v-model="fileList" bizPath="bill"></j-upload>
  319. </a-form-item>
  320. </a-col>
  321. </a-row>
  322. <a-row class="form-row" :gutter="24">
  323. <a-col :lg="6" :md="12" :sm="24">
  324. <a-form-item
  325. :labelCol="labelCol"
  326. :wrapperCol="wrapperCol"
  327. label="凭证图片"
  328. data-step="11"
  329. data-title="附件"
  330. data-intro="可以上传与单据相关的图片、文档,支持多个文件"
  331. >
  332. <j-image-upload v-model="imageList" bizPath="material" text="上传图片" isMultiple></j-image-upload>
  333. </a-form-item>
  334. </a-col>
  335. </a-row>
  336. </a-form>
  337. </a-spin>
  338. <many-account-modal ref="manyAccountModalForm" @ok="manyAccountModalFormOk"></many-account-modal>
  339. <import-item-modal ref="importItemModalForm" @ok="importItemModalFormOk"></import-item-modal>
  340. <vendor-modal ref="vendorModalForm" @ok="vendorModalFormOk"></vendor-modal>
  341. <account-modal ref="accountModalForm" @ok="accountModalFormOk"></account-modal>
  342. <link-bill-list ref="linkBillList" @ok="linkBillListOk"></link-bill-list>
  343. <history-bill-list ref="historyBillListModalForm"></history-bill-list>
  344. <workflow-iframe ref="modalWorkflow" @ok="workflowModalFormOk"></workflow-iframe>
  345. <bill-print-iframe ref="modalPrint"></bill-print-iframe>
  346. </j-modal>
  347. </template>
  348. <script>
  349. import pick from 'lodash.pick'
  350. import ManyAccountModal from '../dialog/ManyAccountModal'
  351. import ImportItemModal from '../dialog/ImportItemModal'
  352. import LinkBillList from '../dialog/LinkBillList'
  353. import VendorModal from '../../system/modules/VendorModal'
  354. import AccountModal from '../../system/modules/AccountModal'
  355. import HistoryBillList from '../dialog/HistoryBillList'
  356. import WorkflowIframe from '@/components/tools/WorkflowIframe'
  357. import BillPrintIframe from '../dialog/BillPrintIframe'
  358. import { FormTypes } from '@/utils/JEditableTableUtil'
  359. import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
  360. import { BillModalMixin } from '../mixins/BillModalMixin'
  361. import { findBillDetailByNumber, getCurrentSystemConfig } from '@/api/api'
  362. import { getMpListShort, changeListFmtMinus, handleIntroJs } from '@/utils/util'
  363. import JUpload from '@/components/jeecg/JUpload'
  364. import JImageUpload from '@/components/jeecg/JImageUpload.vue'
  365. import JDate from '@/components/jeecg/JDate'
  366. import Vue from 'vue'
  367. // import QrcodeVue from 'qrcode.vue'
  368. export default {
  369. name: 'PurchaseOrderModal',
  370. mixins: [JEditableTableMixin, BillModalMixin],
  371. components: {
  372. ManyAccountModal,
  373. ImportItemModal,
  374. LinkBillList,
  375. VendorModal,
  376. AccountModal,
  377. HistoryBillList,
  378. WorkflowIframe,
  379. BillPrintIframe,
  380. JUpload,
  381. JImageUpload,
  382. JDate,
  383. // QrcodeVue,
  384. VNodes: {
  385. functional: true,
  386. render: (h, ctx) => ctx.props.vnodes,
  387. },
  388. },
  389. data() {
  390. return {
  391. title: '操作',
  392. width: '1600px',
  393. moreStatus: false,
  394. // 新增时子表默认添加几行空数据
  395. addDefaultRowNum: 1,
  396. visible: false,
  397. supList: [],
  398. depotList: [],
  399. operTimeStr: '',
  400. prefixNo: 'CGDD',
  401. fileList: [],
  402. imageList: [],
  403. rowCanEdit: true,
  404. //以销定购的场景开关
  405. purchaseBySaleFlag: false,
  406. model: {},
  407. labelCol: {
  408. xs: { span: 24 },
  409. sm: { span: 8 },
  410. },
  411. wrapperCol: {
  412. xs: { span: 24 },
  413. sm: { span: 16 },
  414. },
  415. refKeys: ['materialDataTable'],
  416. tableKeys: ['materialDataTable'],
  417. activeKey: 'materialDataTable',
  418. materialTable: {
  419. loading: false,
  420. dataSource: [],
  421. columns: [
  422. { title: '', key: 'hiddenKey', width: '1%', type: FormTypes.hidden },
  423. {
  424. title: '批次号',
  425. key: 'batchNumber',
  426. width: '12%',
  427. type: FormTypes.popupJsh,
  428. kind: 'material',
  429. multi: true,
  430. validateRules: [{ required: true, message: '${title}不能为空' }],
  431. },
  432. { title: '名称', key: 'name', width: '10%', type: FormTypes.normal },
  433. { title: '规格', key: 'standard', width: '9%', type: FormTypes.normal },
  434. { title: '生产日期', key: 'productionDate', width: '9%', type: FormTypes.normal },
  435. { title: '保质期', key: 'expiryNum', width: '6%', type: FormTypes.normal },
  436. { title: '商品条码', key: 'barCode', width: '6%', type: FormTypes.normal },
  437. { title: '仓库名', key: 'depotId', width: '9%', type: FormTypes.select, disabled: true },
  438. { title: '仓库货架', key: 'position', width: '6%', type: FormTypes.normal },
  439. { title: '包装规格', key: 'unitName', width: '6%', type: FormTypes.normal },
  440. { title: '型号', key: 'model', width: '9%', type: FormTypes.normal },
  441. { title: '颜色', key: 'color', width: '5%', type: FormTypes.normal },
  442. { title: '品牌', key: 'brand', width: '6%', type: FormTypes.normal },
  443. { title: '制造商', key: 'mfrs', width: '6%', type: FormTypes.normal },
  444. { title: '扩展信息', key: 'materialOther', width: '5%', type: FormTypes.normal },
  445. { title: '库存', key: 'stock', width: '5%', type: FormTypes.normal },
  446. {
  447. title: '单位',
  448. key: 'unit',
  449. width: '6%',
  450. type: FormTypes.slot,
  451. options: [],
  452. allowClear: false,
  453. slotName: 'unit',
  454. },
  455. { title: '单位id', key: 'unitId', width: '4%', type: FormTypes.hidden },
  456. { title: '单位列表', key: 'unitList', width: '5%', type: FormTypes.hidden },
  457. { title: '多属性', key: 'sku', width: '9%', type: FormTypes.normal },
  458. { title: '原数量', key: 'preNumber', width: '4%', type: FormTypes.normal },
  459. { title: '已采购', key: 'finishNumber', width: '4%', type: FormTypes.normal },
  460. {
  461. title: '数量',
  462. key: 'operNumber',
  463. width: '5%',
  464. type: FormTypes.inputNumber,
  465. statistics: true,
  466. validateRules: [{ required: true, message: '${title}不能为空' }],
  467. },
  468. { title: '单价', key: 'unitPrice', width: '5%', type: FormTypes.inputNumber },
  469. { title: '金额', key: 'allPrice', width: '5%', type: FormTypes.inputNumber, statistics: true },
  470. // {
  471. // title: '实际入库数量',
  472. // key: 'actualQuantityInStorage',
  473. // width: '9%',
  474. // type: FormTypes.inputNumber,
  475. // validateRules: [{ required: true, message: '实际入库数量不能为空' }],
  476. // },
  477. // { title: '入库差异', key: 'warehousingVariance', width: '9%', type: FormTypes.input },
  478. // { title: '入库差异原因', key: 'reasonOfDifference', width: '9%', type: FormTypes.input },
  479. // {
  480. // title: '入库人',
  481. // key: 'warehousingUser',
  482. // width: '9%',
  483. // type: FormTypes.input,
  484. // validateRules: [{ required: true, message: '入库人不能为空' }],
  485. // },
  486. // { title: '入库时间', key: 'warehousingTime', width: '9%', type: FormTypes.date },
  487. { title: '税率', key: 'taxRate', width: '4%', type: FormTypes.inputNumber, placeholder: '%' },
  488. {
  489. title: '税额',
  490. key: 'taxMoney',
  491. width: '5%',
  492. type: FormTypes.inputNumber,
  493. readonly: true,
  494. statistics: true,
  495. },
  496. { title: '价税合计', key: 'taxLastMoney', width: '7%', type: FormTypes.inputNumber, statistics: true },
  497. { title: '备注', key: 'remark', width: '6%', type: FormTypes.input },
  498. { title: '关联id', key: 'linkId', width: '5%', type: FormTypes.hidden },
  499. ],
  500. },
  501. confirmLoading: false,
  502. validatorRules: {
  503. operTime: {
  504. rules: [{ required: true, message: '请输入单据日期!' }],
  505. },
  506. organId: {
  507. rules: [{ required: true, message: '请选择供应商!' }],
  508. },
  509. },
  510. url: {
  511. add: '/depotHead/addDepotHeadAndDetail',
  512. edit: '/depotHead/updateDepotHeadAndDetail',
  513. detailList: '/depotItem/getDetailList',
  514. importExcelUrl: '/depotItem/importItemExcel',
  515. },
  516. unitList: [],
  517. }
  518. },
  519. created() {},
  520. methods: {
  521. //调用完edit()方法之后会自动调用此方法
  522. editAfter() {
  523. this.billStatus = '0'
  524. this.currentSelectDepotId = ''
  525. this.rowCanEdit = true
  526. this.materialTable.columns[1].type = FormTypes.popupJsh
  527. this.changeColumnHide()
  528. this.changeFormTypes(this.materialTable.columns, 'preNumber', 0)
  529. this.changeFormTypes(this.materialTable.columns, 'finishNumber', 0)
  530. if (this.action === 'add') {
  531. this.addInit(this.prefixNo)
  532. this.fileList = []
  533. this.imageList = []
  534. this.$nextTick(() => {
  535. handleIntroJs(this.prefixNo, 1)
  536. })
  537. } else {
  538. if (this.model.linkNumber) {
  539. this.rowCanEdit = false
  540. this.materialTable.columns[1].type = FormTypes.normal
  541. }
  542. this.model.operTime = this.model.operTimeStr
  543. if (this.model.accountId == null && this.model.accountIdList) {
  544. this.model.accountId = 0
  545. this.manyAccountBtnStatus = true
  546. this.accountIdList = this.model.accountIdList
  547. this.accountMoneyList = this.model.accountMoneyList
  548. } else {
  549. this.manyAccountBtnStatus = false
  550. }
  551. this.fileList = this.model.fileName
  552. this.imageList = this.model.voucherPicture
  553. this.$nextTick(() => {
  554. this.form.setFieldsValue(
  555. pick(
  556. this.model,
  557. 'organId',
  558. 'operTime',
  559. 'number',
  560. 'linkApply',
  561. 'linkNumber',
  562. 'remark',
  563. 'discount',
  564. 'discountMoney',
  565. 'discountLastMoney',
  566. 'accountId',
  567. 'changeAmount'
  568. )
  569. )
  570. })
  571. // 加载子表数据
  572. let params = {
  573. headerId: this.model.id,
  574. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  575. linkType: 'basic',
  576. }
  577. let url = this.readOnly ? this.url.detailList : this.url.detailList
  578. this.requestSubTableData(url, params, this.materialTable)
  579. }
  580. //复制新增单据-初始化单号和日期
  581. if (this.action === 'copyAdd') {
  582. this.model.id = ''
  583. this.model.tenantId = ''
  584. this.copyAddInit(this.prefixNo)
  585. }
  586. this.initSystemConfig()
  587. this.initSupplier(0)
  588. this.initAccount(0)
  589. this.initPlatform()
  590. this.initQuickBtn()
  591. this.initDepot()
  592. },
  593. /** 整理成formData */
  594. classifyIntoFormData(allValues) {
  595. let totalPrice = 0
  596. let billMain = Object.assign(this.model, allValues.formValue)
  597. let detailArr = allValues.tablesValue[0].values
  598. billMain.type = '其它'
  599. billMain.subType = '采购订单'
  600. for (let item of detailArr) {
  601. // item.depotId = '' //订单不需要仓库
  602. totalPrice += item.allPrice - 0
  603. }
  604. billMain.totalPrice = 0 - totalPrice
  605. billMain.changeAmount = 0 - billMain.changeAmount
  606. if (billMain.accountId === 0) {
  607. billMain.accountId = ''
  608. }
  609. this.accountMoneyList = changeListFmtMinus(this.accountMoneyList)
  610. billMain.accountIdList = this.accountIdList.length > 0 ? JSON.stringify(this.accountIdList) : ''
  611. billMain.accountMoneyList = this.accountMoneyList.length > 0 ? JSON.stringify(this.accountMoneyList) : ''
  612. if (this.fileList && this.fileList.length > 0) {
  613. billMain.fileName = this.fileList
  614. } else {
  615. billMain.fileName = ''
  616. }
  617. if (this.imageList && this.imageList.length > 0) {
  618. billMain.voucherPicture = this.imageList
  619. } else {
  620. billMain.voucherPicture = ''
  621. }
  622. if (this.model.id) {
  623. billMain.id = this.model.id
  624. }
  625. billMain.status = this.billStatus
  626. return {
  627. info: JSON.stringify(billMain),
  628. rows: JSON.stringify(detailArr),
  629. }
  630. },
  631. handleHistoryBillList() {
  632. let organId = this.form.getFieldValue('organId')
  633. this.$refs.historyBillListModalForm.show('其它', '采购订单', '供应商', organId)
  634. this.$refs.historyBillListModalForm.disableSubmit = false
  635. },
  636. onSearchLinkNumber() {
  637. this.$refs.linkBillList.purchaseShow('其它', '销售订单', '客户', '1,3', '0,3')
  638. this.$refs.linkBillList.title = '请选择销售订单'
  639. },
  640. onSearchLinkApply() {
  641. this.$refs.linkBillList.purchaseShow('其它', '请购单', '客户', '1,3')
  642. this.$refs.linkBillList.title = '请选择请购单'
  643. },
  644. linkBillListOk(selectBillDetailRows, linkNumber, organId) {
  645. this.rowCanEdit = false
  646. this.materialTable.columns[1].type = FormTypes.normal
  647. this.changeFormTypes(this.materialTable.columns, 'preNumber', 1)
  648. this.changeFormTypes(this.materialTable.columns, 'finishNumber', 1)
  649. if (selectBillDetailRows && selectBillDetailRows.length > 0) {
  650. let discountLastMoney = 0
  651. for (let j = 0; j < selectBillDetailRows.length; j++) {
  652. let info = selectBillDetailRows[j]
  653. if (info.preNumber) {
  654. info.operNumber = info.preNumber - info.finishNumber
  655. info.unitPrice = info.purchaseDecimal
  656. info.allPrice = (info.operNumber * info.unitPrice).toFixed(2) - 0
  657. info.taxRate = 0
  658. info.taxMoney = 0
  659. info.taxLastMoney = info.allPrice
  660. discountLastMoney += info.allPrice
  661. }
  662. info.linkId = info.id
  663. this.changeColumnShow(info)
  664. }
  665. //根据单号查询单据类型
  666. findBillDetailByNumber({ number: linkNumber }).then((res) => {
  667. if (res.code === 200) {
  668. if (res.data && res.data.subType === '请购单') {
  669. //关联请购单
  670. this.$nextTick(() => {
  671. this.form.setFieldsValue({
  672. linkApply: linkNumber,
  673. })
  674. })
  675. } else {
  676. this.$nextTick(() => {
  677. this.form.setFieldsValue({
  678. linkNumber: linkNumber,
  679. })
  680. })
  681. }
  682. }
  683. })
  684. //给优惠后金额重新赋值
  685. discountLastMoney = discountLastMoney ? discountLastMoney : 0
  686. this.$nextTick(() => {
  687. this.form.setFieldsValue({
  688. discountLastMoney: discountLastMoney.toFixed(2),
  689. changeAmount: discountLastMoney.toFixed(2),
  690. })
  691. })
  692. this.materialTable.dataSource = selectBillDetailRows
  693. }
  694. },
  695. getUnitInfo(val) {
  696. this.unitList = val
  697. },
  698. },
  699. }
  700. </script>
  701. <style scoped></style>