PurchaseInModal.vue 33 KB

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