PurchaseOrderModal.vue 30 KB

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