PurchaseInModal.vue 30 KB

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