PurchaseOrderModal.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  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-form>
  323. </a-spin>
  324. <many-account-modal ref="manyAccountModalForm" @ok="manyAccountModalFormOk"></many-account-modal>
  325. <import-item-modal ref="importItemModalForm" @ok="importItemModalFormOk"></import-item-modal>
  326. <vendor-modal ref="vendorModalForm" @ok="vendorModalFormOk"></vendor-modal>
  327. <account-modal ref="accountModalForm" @ok="accountModalFormOk"></account-modal>
  328. <link-bill-list ref="linkBillList" @ok="linkBillListOk"></link-bill-list>
  329. <history-bill-list ref="historyBillListModalForm"></history-bill-list>
  330. <workflow-iframe ref="modalWorkflow" @ok="workflowModalFormOk"></workflow-iframe>
  331. <bill-print-iframe ref="modalPrint"></bill-print-iframe>
  332. </j-modal>
  333. </template>
  334. <script>
  335. import pick from 'lodash.pick'
  336. import ManyAccountModal from '../dialog/ManyAccountModal'
  337. import ImportItemModal from '../dialog/ImportItemModal'
  338. import LinkBillList from '../dialog/LinkBillList'
  339. import VendorModal from '../../system/modules/VendorModal'
  340. import AccountModal from '../../system/modules/AccountModal'
  341. import HistoryBillList from '../dialog/HistoryBillList'
  342. import WorkflowIframe from '@/components/tools/WorkflowIframe'
  343. import BillPrintIframe from '../dialog/BillPrintIframe'
  344. import { FormTypes } from '@/utils/JEditableTableUtil'
  345. import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
  346. import { BillModalMixin } from '../mixins/BillModalMixin'
  347. import { findBillDetailByNumber, getCurrentSystemConfig } from '@/api/api'
  348. import { getMpListShort, changeListFmtMinus, handleIntroJs } from '@/utils/util'
  349. import JUpload from '@/components/jeecg/JUpload'
  350. import JDate from '@/components/jeecg/JDate'
  351. import Vue from 'vue'
  352. export default {
  353. name: 'PurchaseOrderModal',
  354. mixins: [JEditableTableMixin, BillModalMixin],
  355. components: {
  356. ManyAccountModal,
  357. ImportItemModal,
  358. LinkBillList,
  359. VendorModal,
  360. AccountModal,
  361. HistoryBillList,
  362. WorkflowIframe,
  363. BillPrintIframe,
  364. JUpload,
  365. JDate,
  366. VNodes: {
  367. functional: true,
  368. render: (h, ctx) => ctx.props.vnodes,
  369. },
  370. },
  371. data() {
  372. return {
  373. title: '操作',
  374. width: '1600px',
  375. moreStatus: false,
  376. // 新增时子表默认添加几行空数据
  377. addDefaultRowNum: 1,
  378. visible: false,
  379. supList: [],
  380. depotList: [],
  381. operTimeStr: '',
  382. prefixNo: 'CGDD',
  383. fileList: [],
  384. rowCanEdit: true,
  385. //以销定购的场景开关
  386. purchaseBySaleFlag: false,
  387. model: {},
  388. labelCol: {
  389. xs: { span: 24 },
  390. sm: { span: 8 },
  391. },
  392. wrapperCol: {
  393. xs: { span: 24 },
  394. sm: { span: 16 },
  395. },
  396. refKeys: ['materialDataTable'],
  397. tableKeys: ['materialDataTable'],
  398. activeKey: 'materialDataTable',
  399. materialTable: {
  400. loading: false,
  401. dataSource: [],
  402. columns: [
  403. { title: '', key: 'hiddenKey', width: '1%', type: FormTypes.hidden },
  404. {
  405. title: '批次号',
  406. key: 'batchNumber',
  407. width: '12%',
  408. type: FormTypes.popupJsh,
  409. kind: 'material',
  410. multi: true,
  411. validateRules: [{ required: true, message: '${title}不能为空' }],
  412. },
  413. { title: '名称', key: 'name', width: '10%', type: FormTypes.normal },
  414. { title: '规格', key: 'standard', width: '9%', type: FormTypes.normal },
  415. { title: '生产日期', key: 'productionDate', width: '9%', type: FormTypes.normal },
  416. { title: '保质期', key: 'expiryNum', width: '6%', type: FormTypes.normal },
  417. { title: '商品条码', key: 'barCode', width: '6%', type: FormTypes.normal },
  418. { title: '仓库名', key: 'depotName', width: '6%', type: FormTypes.normal },
  419. { title: '仓库货架', key: 'position', width: '6%', type: FormTypes.normal },
  420. { title: '包装规格', key: 'unitName', width: '6%', type: FormTypes.input },
  421. { title: '型号', key: 'model', width: '9%', type: FormTypes.normal },
  422. { title: '颜色', key: 'color', width: '5%', type: FormTypes.normal },
  423. { title: '品牌', key: 'brand', width: '6%', type: FormTypes.normal },
  424. { title: '制造商', key: 'mfrs', width: '6%', type: FormTypes.normal },
  425. { title: '扩展信息', key: 'materialOther', width: '5%', type: FormTypes.normal },
  426. { title: '库存', key: 'stock', width: '5%', type: FormTypes.normal },
  427. {
  428. title: '单位',
  429. key: 'unit',
  430. width: '6%',
  431. type: FormTypes.slot,
  432. options: [],
  433. allowClear: false,
  434. slotName: 'unit',
  435. },
  436. { title: '单位id', key: 'unitId', width: '4%', type: FormTypes.hidden },
  437. { title: '单位列表', key: 'unitList', width: '5%', type: FormTypes.hidden },
  438. { title: '多属性', key: 'sku', width: '9%', type: FormTypes.normal },
  439. { title: '原数量', key: 'preNumber', width: '4%', type: FormTypes.normal },
  440. { title: '已采购', key: 'finishNumber', width: '4%', type: FormTypes.normal },
  441. {
  442. title: '数量',
  443. key: 'operNumber',
  444. width: '5%',
  445. type: FormTypes.inputNumber,
  446. statistics: true,
  447. validateRules: [{ required: true, message: '${title}不能为空' }],
  448. },
  449. { title: '单价', key: 'unitPrice', width: '5%', type: FormTypes.inputNumber },
  450. { title: '金额', key: 'allPrice', width: '5%', type: FormTypes.inputNumber, statistics: true },
  451. {
  452. title: '实际入库数量',
  453. key: 'actualQuantityInStorage',
  454. width: '9%',
  455. type: FormTypes.inputNumber,
  456. validateRules: [{ required: true, message: '实际入库数量不能为空' }],
  457. },
  458. { title: '入库差异', key: 'warehousingVariance', width: '9%', type: FormTypes.input },
  459. { title: '入库差异原因', key: 'reasonOfDifference', width: '9%', type: FormTypes.input },
  460. {
  461. title: '入库人',
  462. key: 'warehousingUser',
  463. width: '9%',
  464. type: FormTypes.input,
  465. validateRules: [{ required: true, message: '入库人不能为空' }],
  466. },
  467. { title: '入库时间', key: 'warehousingTime', width: '9%', type: FormTypes.date },
  468. { title: '税率', key: 'taxRate', width: '4%', type: FormTypes.inputNumber, placeholder: '%' },
  469. {
  470. title: '税额',
  471. key: 'taxMoney',
  472. width: '5%',
  473. type: FormTypes.inputNumber,
  474. readonly: true,
  475. statistics: true,
  476. },
  477. { title: '价税合计', key: 'taxLastMoney', width: '7%', type: FormTypes.inputNumber, statistics: true },
  478. { title: '备注', key: 'remark', width: '6%', type: FormTypes.input },
  479. { title: '关联id', key: 'linkId', width: '5%', type: FormTypes.hidden },
  480. ],
  481. },
  482. confirmLoading: false,
  483. validatorRules: {
  484. operTime: {
  485. rules: [{ required: true, message: '请输入单据日期!' }],
  486. },
  487. organId: {
  488. rules: [{ required: true, message: '请选择供应商!' }],
  489. },
  490. },
  491. url: {
  492. add: '/depotHead/addDepotHeadAndDetail',
  493. edit: '/depotHead/updateDepotHeadAndDetail',
  494. detailList: '/depotItem/getDetailList',
  495. importExcelUrl: '/depotItem/importItemExcel',
  496. },
  497. unitList: [],
  498. }
  499. },
  500. created() {},
  501. methods: {
  502. //调用完edit()方法之后会自动调用此方法
  503. editAfter() {
  504. this.billStatus = '0'
  505. this.currentSelectDepotId = ''
  506. this.rowCanEdit = true
  507. this.materialTable.columns[1].type = FormTypes.popupJsh
  508. this.changeColumnHide()
  509. this.changeFormTypes(this.materialTable.columns, 'preNumber', 0)
  510. this.changeFormTypes(this.materialTable.columns, 'finishNumber', 0)
  511. if (this.action === 'add') {
  512. this.addInit(this.prefixNo)
  513. this.fileList = []
  514. this.$nextTick(() => {
  515. handleIntroJs(this.prefixNo, 1)
  516. })
  517. } else {
  518. if (this.model.linkNumber) {
  519. this.rowCanEdit = false
  520. this.materialTable.columns[1].type = FormTypes.normal
  521. }
  522. this.model.operTime = this.model.operTimeStr
  523. if (this.model.accountId == null && this.model.accountIdList) {
  524. this.model.accountId = 0
  525. this.manyAccountBtnStatus = true
  526. this.accountIdList = this.model.accountIdList
  527. this.accountMoneyList = this.model.accountMoneyList
  528. } else {
  529. this.manyAccountBtnStatus = false
  530. }
  531. this.fileList = this.model.fileName
  532. this.$nextTick(() => {
  533. this.form.setFieldsValue(
  534. pick(
  535. this.model,
  536. 'organId',
  537. 'operTime',
  538. 'number',
  539. 'linkApply',
  540. 'linkNumber',
  541. 'remark',
  542. 'discount',
  543. 'discountMoney',
  544. 'discountLastMoney',
  545. 'accountId',
  546. 'changeAmount'
  547. )
  548. )
  549. })
  550. // 加载子表数据
  551. let params = {
  552. headerId: this.model.id,
  553. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  554. linkType: 'basic',
  555. }
  556. let url = this.readOnly ? this.url.detailList : this.url.detailList
  557. this.requestSubTableData(url, params, this.materialTable)
  558. }
  559. //复制新增单据-初始化单号和日期
  560. if (this.action === 'copyAdd') {
  561. this.model.id = ''
  562. this.model.tenantId = ''
  563. this.copyAddInit(this.prefixNo)
  564. }
  565. this.initSystemConfig()
  566. this.initSupplier(0)
  567. this.initAccount(0)
  568. this.initPlatform()
  569. this.initQuickBtn()
  570. },
  571. /** 整理成formData */
  572. classifyIntoFormData(allValues) {
  573. let totalPrice = 0
  574. let billMain = Object.assign(this.model, allValues.formValue)
  575. let detailArr = allValues.tablesValue[0].values
  576. billMain.type = '其它'
  577. billMain.subType = '采购订单'
  578. for (let item of detailArr) {
  579. item.depotId = '' //订单不需要仓库
  580. totalPrice += item.allPrice - 0
  581. }
  582. billMain.totalPrice = 0 - totalPrice
  583. billMain.changeAmount = 0 - billMain.changeAmount
  584. if (billMain.accountId === 0) {
  585. billMain.accountId = ''
  586. }
  587. this.accountMoneyList = changeListFmtMinus(this.accountMoneyList)
  588. billMain.accountIdList = this.accountIdList.length > 0 ? JSON.stringify(this.accountIdList) : ''
  589. billMain.accountMoneyList = this.accountMoneyList.length > 0 ? JSON.stringify(this.accountMoneyList) : ''
  590. if (this.fileList && this.fileList.length > 0) {
  591. billMain.fileName = this.fileList
  592. } else {
  593. billMain.fileName = ''
  594. }
  595. if (this.model.id) {
  596. billMain.id = this.model.id
  597. }
  598. billMain.status = this.billStatus
  599. return {
  600. info: JSON.stringify(billMain),
  601. rows: JSON.stringify(detailArr),
  602. }
  603. },
  604. handleHistoryBillList() {
  605. let organId = this.form.getFieldValue('organId')
  606. this.$refs.historyBillListModalForm.show('其它', '采购订单', '供应商', organId)
  607. this.$refs.historyBillListModalForm.disableSubmit = false
  608. },
  609. onSearchLinkNumber() {
  610. this.$refs.linkBillList.purchaseShow('其它', '销售订单', '客户', '1,3', '0,3')
  611. this.$refs.linkBillList.title = '请选择销售订单'
  612. },
  613. onSearchLinkApply() {
  614. this.$refs.linkBillList.purchaseShow('其它', '请购单', '客户', '1,3')
  615. this.$refs.linkBillList.title = '请选择请购单'
  616. },
  617. linkBillListOk(selectBillDetailRows, linkNumber, organId) {
  618. this.rowCanEdit = false
  619. this.materialTable.columns[1].type = FormTypes.normal
  620. this.changeFormTypes(this.materialTable.columns, 'preNumber', 1)
  621. this.changeFormTypes(this.materialTable.columns, 'finishNumber', 1)
  622. if (selectBillDetailRows && selectBillDetailRows.length > 0) {
  623. let discountLastMoney = 0
  624. for (let j = 0; j < selectBillDetailRows.length; j++) {
  625. let info = selectBillDetailRows[j]
  626. if (info.preNumber) {
  627. info.operNumber = info.preNumber - info.finishNumber
  628. info.unitPrice = info.purchaseDecimal
  629. info.allPrice = (info.operNumber * info.unitPrice).toFixed(2) - 0
  630. info.taxRate = 0
  631. info.taxMoney = 0
  632. info.taxLastMoney = info.allPrice
  633. discountLastMoney += info.allPrice
  634. }
  635. info.linkId = info.id
  636. this.changeColumnShow(info)
  637. }
  638. //根据单号查询单据类型
  639. findBillDetailByNumber({ number: linkNumber }).then((res) => {
  640. if (res.code === 200) {
  641. if (res.data && res.data.subType === '请购单') {
  642. //关联请购单
  643. this.$nextTick(() => {
  644. this.form.setFieldsValue({
  645. linkApply: linkNumber,
  646. })
  647. })
  648. } else {
  649. this.$nextTick(() => {
  650. this.form.setFieldsValue({
  651. linkNumber: linkNumber,
  652. })
  653. })
  654. }
  655. }
  656. })
  657. //给优惠后金额重新赋值
  658. discountLastMoney = discountLastMoney ? discountLastMoney : 0
  659. this.$nextTick(() => {
  660. this.form.setFieldsValue({
  661. discountLastMoney: discountLastMoney.toFixed(2),
  662. changeAmount: discountLastMoney.toFixed(2),
  663. })
  664. })
  665. this.materialTable.dataSource = selectBillDetailRows
  666. }
  667. },
  668. getUnitInfo(val) {
  669. this.unitList = val
  670. },
  671. },
  672. }
  673. </script>
  674. <style scoped></style>