PurchaseInModal.vue 31 KB

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