OtherInModal.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  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. switchFullscreen
  12. @cancel="handleCancel"
  13. :id="prefixNo"
  14. style="top: 20px; height: 95%"
  15. >
  16. <template slot="footer">
  17. <a-button @click="handleCancel">取消</a-button>
  18. <a-button v-if="billPrintFlag && isShowPrintBtn" @click="handlePrint('其它入库')">三联打印预览</a-button>
  19. <a-button v-if="checkFlag && isCanCheck" :loading="confirmLoading" @click="handleOkAndCheck">保存并审核</a-button>
  20. <a-button type="primary" :loading="confirmLoading" @click="handleOk">保存(Ctrl+S)</a-button>
  21. <!--发起多级审核-->
  22. <a-button v-if="!checkFlag" @click="handleWorkflow()" type="primary">提交流程</a-button>
  23. </template>
  24. <a-spin :spinning="confirmLoading">
  25. <a-form :form="form">
  26. <a-row class="form-row" :gutter="24">
  27. <a-col :lg="6" :md="12" :sm="24">
  28. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="供应商">
  29. <a-select
  30. placeholder="请选择供应商"
  31. v-decorator="['organId', validatorRules.organId]"
  32. :disabled="!rowCanEdit"
  33. :dropdownMatchSelectWidth="false"
  34. showSearch
  35. optionFilterProp="children"
  36. @change="getTatRate"
  37. >
  38. <div slot="dropdownRender" slot-scope="menu">
  39. <v-nodes :vnodes="menu" />
  40. <a-divider style="margin: 4px 0" />
  41. <div
  42. v-if="quickBtn.vendor"
  43. style="padding: 4px 8px; cursor: pointer"
  44. @mousedown="(e) => e.preventDefault()"
  45. @click="addSupplier"
  46. >
  47. <a-icon type="plus" /> 新增供应商
  48. </div>
  49. </div>
  50. <a-select-option v-for="(item, index) in supList" :key="index" :value="item.id">
  51. {{ item.supplier }}
  52. </a-select-option>
  53. </a-select>
  54. </a-form-item>
  55. </a-col>
  56. <a-col :lg="6" :md="12" :sm="24">
  57. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="单据日期">
  58. <j-date v-decorator="['operTime', validatorRules.operTime]" :show-time="true" />
  59. </a-form-item>
  60. </a-col>
  61. <a-col :lg="6" :md="12" :sm="24">
  62. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="单据编号">
  63. <a-input placeholder="请输入单据编号" v-decorator.trim="['number']" />
  64. </a-form-item>
  65. </a-col>
  66. <a-col :lg="6" :md="12" :sm="24">
  67. <a-form-item
  68. :labelCol="labelCol"
  69. :wrapperCol="wrapperCol"
  70. label="仓库名"
  71. >
  72. <a-select v-decorator="['depotId',validatorRules.depotId]" placeholder="请选择仓库名" @change="changeDepot($event,refKeys[0])">
  73. <a-select-option v-for="(item, index) in depotList" :key="index" :value="item.id">
  74. {{ item.depotName }}
  75. </a-select-option>
  76. </a-select>
  77. </a-form-item>
  78. </a-col>
  79. <a-col :lg="6" :md="12" :sm="24">
  80. <a-form-item
  81. :labelCol="labelCol"
  82. :wrapperCol="wrapperCol"
  83. label="税率"
  84. >
  85. <a-input placeholder="自动带出" disabled v-decorator="['taxRate']" />
  86. </a-form-item>
  87. </a-col>
  88. <a-col :lg="6" :md="12" :sm="24">
  89. <a-form-item
  90. v-if="inOutManageFlag && !model.billType"
  91. :labelCol="labelCol"
  92. :wrapperCol="wrapperCol"
  93. label="关联单据"
  94. >
  95. <a-input-search
  96. placeholder="请选择待入库单据"
  97. v-decorator="['linkNumber']"
  98. @search="onSearchLinkNumber"
  99. :readOnly="true"
  100. />
  101. </a-form-item>
  102. </a-col>
  103. </a-row>
  104. <j-editable-table
  105. id="billModal"
  106. :ref="refKeys[0]"
  107. :loading="materialTable.loading"
  108. :columns="materialTable.columns"
  109. :dataSource="materialTable.dataSource"
  110. :minWidth="minWidth"
  111. :maxHeight="300"
  112. :rowNumber="false"
  113. :rowSelection="rowCanEdit"
  114. :actionButton="rowCanEdit"
  115. :dragSortAndNumber="rowCanEdit"
  116. @valueChange="onValueChange"
  117. @added="onAdded"
  118. @deleted="onDeleted"
  119. @focusChange="getUnitInfo"
  120. >
  121. <template #buttonAfter>
  122. <a-row
  123. v-if="rowCanEdit"
  124. :gutter="24"
  125. style="float: left"
  126. data-step="4"
  127. data-title="扫码录入"
  128. data-intro="此功能支持扫码枪扫描商品条码进行录入"
  129. >
  130. <a-col v-if="scanStatus" :md="6" :sm="24">
  131. <a-button @click="scanEnter">扫码录入</a-button>
  132. </a-col>
  133. <a-col v-if="!scanStatus" :md="16" :sm="24" style="padding: 0 8px 0 12px">
  134. <a-input
  135. placeholder="请扫描商品条码并回车"
  136. v-model="scanBarCode"
  137. @pressEnter="scanPressEnter"
  138. ref="scanBarCode"
  139. />
  140. </a-col>
  141. <a-col v-if="!scanStatus" :md="6" :sm="24" style="padding: 0px 12px 0 0">
  142. <a-button @click="stopScan">收起扫码</a-button>
  143. </a-col>
  144. </a-row>
  145. <a-row v-if="rowCanEdit" :gutter="24" style="float: left; padding-bottom: 5px; padding-left: 20px">
  146. <a-button icon="import" @click="onImport(prefixNo)">导入明细</a-button>
  147. </a-row>
  148. </template>
  149. <template #depotId="{ value }">
  150. <a-select
  151. disabled
  152. :value="value"
  153. :options="depotList"
  154. >
  155. </a-select>
  156. </template>
  157. <template #wholesaleDecimal="{ handleChange, value, index,allValues }">
  158. <a-input :value="value" @change="($event) => onChangePrice($event,handleChange)">
  159. <a-tooltip slot="suffix" title="修改后和默认价格不一致">
  160. <a-icon type="info-circle" style="color: #f5222d" v-show="getDefaultWholesaleDecimal(index,'defaultWholesaleDecimal',value,allValues)" />
  161. </a-tooltip>
  162. </a-input>
  163. </template>
  164. <template #unitPrice="{ handleChange, value, index,allValues }">
  165. <a-input :value="value" @change="($event) => onChangePrice($event,handleChange)">
  166. <a-tooltip slot="suffix" title="修改后和默认价格不一致">
  167. <a-icon type="info-circle" style="color: #f5222d" v-show="getDefaultWholesaleDecimal(index,'defaultPurchaseDecimal',value,allValues)" />
  168. </a-tooltip>
  169. </a-input>
  170. </template>
  171. <!-- <template #depotBatchSet>
  172. <a-icon type="down" @click="handleBatchSetDepot" />
  173. </template> -->
  174. <template #unit="{ handleChange, handleFocus, value }">
  175. <a-select
  176. placeholder="请选择"
  177. v-decorator="['unit']"
  178. :dropdownMatchSelectWidth="false"
  179. showSearch
  180. :allowClear="false"
  181. optionFilterProp="children"
  182. :value="value"
  183. @change="($event) => handleChange($event)"
  184. @focus="($event) => handleFocus($event)"
  185. >
  186. <a-select-option v-for="(item, index) in unitList" :key="index" :value="item.name">
  187. {{ item.name }}
  188. </a-select-option>
  189. </a-select>
  190. </template>
  191. <template #warehousingUser="{ handleChange, value }">
  192. <a-select
  193. placeholder="请选择"
  194. v-decorator="['warehousingUser']"
  195. :dropdownMatchSelectWidth="false"
  196. showSearch
  197. :allowClear="false"
  198. optionFilterProp="children"
  199. :value="value"
  200. :options="currentUserList"
  201. @change="($event) => handleChange($event)"
  202. >
  203. </a-select>
  204. </template>
  205. </j-editable-table>
  206. <a-row class="form-row" :gutter="24">
  207. <a-col :lg="24" :md="24" :sm="24">
  208. <a-form-item :labelCol="labelCol" :wrapperCol="{ xs: { span: 24 }, sm: { span: 24 } }" label="">
  209. <a-textarea :rows="1" placeholder="请输入备注" v-decorator="['remark']" style="margin-top: 8px" />
  210. </a-form-item>
  211. </a-col>
  212. </a-row>
  213. <a-row class="form-row" :gutter="24">
  214. <a-col :lg="6" :md="12" :sm="24">
  215. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="附件">
  216. <j-upload v-model="fileList" bizPath="bill"></j-upload>
  217. </a-form-item>
  218. </a-col>
  219. </a-row>
  220. <a-row class="form-row" :gutter="24">
  221. <a-col :lg="6" :md="12" :sm="24">
  222. <a-form-item
  223. :labelCol="labelCol"
  224. :wrapperCol="wrapperCol"
  225. label="凭证图片"
  226. data-step="11"
  227. data-title="附件"
  228. data-intro="可以上传与单据相关的图片、文档,支持多个文件"
  229. >
  230. <j-image-upload v-model="imageList" bizPath="material" text="上传图片" isMultiple></j-image-upload>
  231. </a-form-item>
  232. </a-col>
  233. </a-row>
  234. </a-form>
  235. </a-spin>
  236. <vendor-modal ref="vendorModalForm" @ok="vendorModalFormOk"></vendor-modal>
  237. <depot-modal ref="depotModalForm" @ok="depotModalFormOk"></depot-modal>
  238. <batch-set-depot ref="batchSetDepotModalForm" @ok="batchSetDepotModalFormOk"></batch-set-depot>
  239. <import-item-modal ref="importItemModalForm" @ok="importItemModalFormOk" exportTitle="其它入库导入模版[下载]"></import-item-modal>
  240. <wait-bill-list ref="waitBillList" @ok="waitBillListOk"></wait-bill-list>
  241. <workflow-iframe ref="modalWorkflow" @ok="workflowModalFormOk"></workflow-iframe>
  242. <bill-print-iframe ref="modalPrint"></bill-print-iframe>
  243. </j-modal>
  244. </template>
  245. <script>
  246. import pick from 'lodash.pick'
  247. import VendorModal from '../../system/modules/VendorModal'
  248. import DepotModal from '../../system/modules/DepotModal'
  249. import BatchSetDepot from '../dialog/BatchSetDepot'
  250. import ImportItemModal from '../dialog/ImportItemModal'
  251. import WorkflowIframe from '@/components/tools/WorkflowIframe'
  252. import BillPrintIframe from '../dialog/BillPrintIframe'
  253. import { FormTypes } from '@/utils/JEditableTableUtil'
  254. import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
  255. import { BillModalMixin } from '../mixins/BillModalMixin'
  256. import { getMpListShort } from '@/utils/util'
  257. import JUpload from '@/components/jeecg/JUpload'
  258. import JDate from '@/components/jeecg/JDate'
  259. import Vue from 'vue'
  260. import WaitBillList from '../dialog/WaitBillList'
  261. import JImageUpload from '@/components/jeecg/JImageUpload.vue'
  262. export default {
  263. name: 'OtherInModal',
  264. mixins: [JEditableTableMixin, BillModalMixin],
  265. components: {
  266. VendorModal,
  267. DepotModal,
  268. BatchSetDepot,
  269. ImportItemModal,
  270. WaitBillList,
  271. WorkflowIframe,
  272. BillPrintIframe,
  273. JUpload,
  274. JImageUpload,
  275. JDate,
  276. VNodes: {
  277. functional: true,
  278. render: (h, ctx) => ctx.props.vnodes,
  279. },
  280. },
  281. data() {
  282. return {
  283. title: '操作',
  284. width: '1600px',
  285. moreStatus: false,
  286. // 新增时子表默认添加几行空数据
  287. addDefaultRowNum: 1,
  288. visible: false,
  289. operTimeStr: '',
  290. prefixNo: 'QTRK',
  291. fileList: [],
  292. imageList: [],
  293. rowCanEdit: true,
  294. //出入库管理开关,适合独立仓管场景
  295. inOutManageFlag: false,
  296. model: {},
  297. labelCol: {
  298. xs: { span: 24 },
  299. sm: { span: 8 },
  300. },
  301. wrapperCol: {
  302. xs: { span: 24 },
  303. sm: { span: 16 },
  304. },
  305. refKeys: ['materialDataTable'],
  306. activeKey: 'materialDataTable',
  307. materialTable: {
  308. loading: false,
  309. dataSource: [],
  310. columns: [
  311. {
  312. title: '商品条码',
  313. key: 'barCode',
  314. width: '200px',
  315. type: FormTypes.popupJsh,
  316. kind: 'material2',
  317. multi: true,
  318. validateRules: [{ required: true, message: '${title}不能为空' }],
  319. },
  320. { title: '名称', key: 'name', width: '120px', type: FormTypes.normal },
  321. {
  322. title: '生产日期',
  323. key: 'productionDate',
  324. width: '200px',
  325. type: FormTypes.date,
  326. validateRules: [{ required: true, message: '${title}不能为空' }],
  327. },
  328. { title: '保质期', key: 'expiryNum', width: '120px', type: FormTypes.normal },
  329. { title: '仓库名', key: 'depotId', width: '120px', type: FormTypes.slot},
  330. { title: '仓库货架', key: 'position', width: '120px', type: FormTypes.input },
  331. { title: '包装规格', key: 'unitName', width: '120px', type: FormTypes.normal },
  332. { title: '型号', key: 'model', width: '120px', type: FormTypes.normal },
  333. { title: '颜色', key: 'color', width: '120px', type: FormTypes.normal },
  334. { title: '品牌', key: 'brand', width: '120px', type: FormTypes.normal },
  335. { title: '制造商', key: 'mfrs', width: '120px', type: FormTypes.normal },
  336. { title: '扩展信息', key: 'materialOther', width: '120px', type: FormTypes.normal },
  337. { title: '库存', key: 'stock', width: '120px', type: FormTypes.normal },
  338. {
  339. title: '单位',
  340. key: 'unit',
  341. width: '120px',
  342. type: FormTypes.normal,
  343. },
  344. {
  345. title: '销售价',
  346. key: 'wholesaleDecimal',
  347. width: '120px',
  348. type: FormTypes.slot,
  349. validateRules: [{ required: true, message: '${title}不能为空' },{ pattern: /^(([0-9][0-9]*)|([0]\.\d{0,4}|[0-9][0-9]*\.\d{0,4}))$/, message: '金额格式不正确!' }],
  350. },
  351. { title: '单位id', key: 'unitId', width: '120px', type: FormTypes.hidden },
  352. { title: '单位列表', key: 'unitList', width: '120px', type: FormTypes.hidden },
  353. { title: '序列号', key: 'snList', width: '120px', type: FormTypes.popupJsh, kind: 'snAdd', multi: true },
  354. { title: '有效期', key: 'expirationDate', width: '120px', type: FormTypes.date },
  355. { title: '多属性', key: 'sku', width: '120px', type: FormTypes.normal },
  356. { title: '原数量', key: 'preNumber', width: '120px', type: FormTypes.normal },
  357. { title: '已入库', key: 'finishNumber', width: '120px', type: FormTypes.normal },
  358. {
  359. title: '入库数量',
  360. key: 'operNumber',
  361. width: '120px',
  362. type: FormTypes.inputNumber,
  363. statistics: true,
  364. validateRules: [{ required: true, message: '${title}不能为空' }],
  365. },
  366. { 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: '金额格式不正确!' }], },
  367. { title: '金额', key: 'allPrice', width: '120px', type: FormTypes.inputNumber,disabled: true, statistics: true },
  368. { title: '入库差异', key: 'warehousingVariance', width: '120px', type: FormTypes.hidden },
  369. { title: '入库差异原因', key: 'reasonOfDifference', width: '120px', type: FormTypes.hidden },
  370. {
  371. title: '入库人',
  372. key: 'warehousingUser',
  373. width: '120px',
  374. type: FormTypes.slot,
  375. slotName: 'warehousingUser',
  376. validateRules: [{ required: true, message: '入库人不能为空' }],
  377. },
  378. { title: '入库时间', key: 'warehousingTime', width: '200px', type: FormTypes.date },
  379. { title: '备注', key: 'remark', width: '200px', type: FormTypes.input },
  380. { title: '关联id', key: 'linkId', width: '120px', type: FormTypes.hidden },
  381. { title: '默认销售价', key: 'defaultWholesaleDecimal', width: '120px', type: FormTypes.hidden },
  382. { title: '默认采购价', key: 'defaultPurchaseDecimal', width: '120px', type: FormTypes.hidden },
  383. { title: '单位换算比例', key: 'ratio', width: '120px', type: FormTypes.hidden },
  384. ],
  385. },
  386. confirmLoading: false,
  387. validatorRules: {
  388. organId: {
  389. rules: [{ required: true, message: '请选择供应商!' }],
  390. },
  391. operTime: {
  392. rules: [{ required: true, message: '请输入单据日期!' }],
  393. },
  394. type: {
  395. rules: [{ required: true, message: '请选择类型!' }],
  396. },
  397. depotId: {
  398. rules: [{ required: true, message: '请选择仓库名!' }],
  399. },
  400. },
  401. url: {
  402. add: '/depotHead/addDepotHeadAndDetail',
  403. edit: '/depotHead/updateDepotHeadAndDetail',
  404. detailList: '/depotItem/getDetailList',
  405. },
  406. unitList: [],
  407. }
  408. },
  409. created() {},
  410. methods: {
  411. //调用完edit()方法之后会自动调用此方法
  412. editAfter() {
  413. this.billStatus = '0'
  414. this.rowCanEdit = true
  415. this.materialTable.columns[0].type = FormTypes.popupJsh
  416. this.changeColumnHide()
  417. this.changeFormTypes(this.materialTable.columns, 'snList', 0)
  418. // this.changeFormTypes(this.materialTable.columns, 'batchNumber', 0)
  419. this.changeFormTypes(this.materialTable.columns, 'expirationDate', 0)
  420. this.changeFormTypes(this.materialTable.columns, 'preNumber', 0)
  421. this.changeFormTypes(this.materialTable.columns, 'finishNumber', 0)
  422. if (this.action === 'add') {
  423. this.addInit(this.prefixNo)
  424. this.fileList = []
  425. this.imageList = []
  426. } else {
  427. // if (this.model.linkNumber) {
  428. // this.rowCanEdit = false
  429. // this.materialTable.columns[1].type = FormTypes.normal
  430. // }
  431. this.model.operTime = this.model.operTimeStr
  432. this.fileList = this.model.fileName
  433. this.imageList = this.model.voucherPicture
  434. this.$nextTick(() => {
  435. this.form.setFieldsValue(
  436. pick(
  437. this.model,
  438. 'organId',
  439. 'operTime',
  440. 'number',
  441. 'linkNumber',
  442. 'remark',
  443. 'discount',
  444. 'discountMoney',
  445. 'discountLastMoney',
  446. 'otherMoney',
  447. 'accountId',
  448. 'changeAmount',
  449. 'depotId',
  450. 'taxRate'
  451. )
  452. )
  453. })
  454. // 加载子表数据
  455. let params = {
  456. headerId: this.model.id,
  457. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  458. linkType: 'basic',
  459. }
  460. let url = this.readOnly ? this.url.detailList : this.url.detailList
  461. this.requestSubTableData(url, params, this.materialTable)
  462. }
  463. //复制新增单据-初始化单号和日期
  464. if (this.action === 'copyAdd') {
  465. this.model.id = ''
  466. this.model.tenantId = ''
  467. this.copyAddInit(this.prefixNo)
  468. }
  469. this.initSystemConfig()
  470. this.initSupplier(0)
  471. this.initDepot()
  472. this.initPlatform()
  473. this.initQuickBtn()
  474. },
  475. //提交单据时整理成formData
  476. classifyIntoFormData(allValues) {
  477. let totalPrice = 0
  478. let billMain = Object.assign(this.model, allValues.formValue)
  479. let detailArr = allValues.tablesValue[0].values
  480. billMain.type = '入库'
  481. billMain.subType = '其它'
  482. for (let item of detailArr) {
  483. totalPrice += item.allPrice - 0
  484. }
  485. billMain.totalPrice = 0 - totalPrice
  486. if (this.fileList && this.fileList.length > 0) {
  487. billMain.fileName = this.fileList
  488. } else {
  489. billMain.fileName = ''
  490. }
  491. if (this.imageList && this.imageList.length > 0) {
  492. billMain.voucherPicture = this.imageList
  493. } else {
  494. billMain.voucherPicture = ''
  495. }
  496. if (this.model.id) {
  497. billMain.id = this.model.id
  498. }
  499. billMain.status = this.billStatus
  500. return {
  501. info: JSON.stringify(billMain),
  502. rows: JSON.stringify(detailArr),
  503. }
  504. },
  505. onSearchLinkNumber() {
  506. this.$refs.waitBillList.show('入库', '采购,销售退货', '1,3')
  507. this.$refs.waitBillList.title = '请选择采购入库或销售退货'
  508. },
  509. waitBillListOk(selectBillDetailRows, linkNumber, remark, organId) {
  510. this.rowCanEdit = false
  511. this.materialTable.columns[1].type = FormTypes.normal
  512. this.changeFormTypes(this.materialTable.columns, 'preNumber', 1)
  513. this.changeFormTypes(this.materialTable.columns, 'finishNumber', 1)
  514. if (selectBillDetailRows && selectBillDetailRows.length > 0) {
  515. let listEx = []
  516. for (let j = 0; j < selectBillDetailRows.length; j++) {
  517. let info = selectBillDetailRows[j]
  518. if (info.finishNumber > 0) {
  519. info.operNumber = info.preNumber - info.finishNumber
  520. }
  521. info.unitPrice = 0
  522. info.allPrice = 0
  523. info.linkId = info.id
  524. listEx.push(info)
  525. this.changeColumnShow(info)
  526. }
  527. this.materialTable.dataSource = listEx
  528. this.$nextTick(() => {
  529. this.form.setFieldsValue({
  530. linkNumber: linkNumber,
  531. remark: remark,
  532. organId: organId?String(organId):'',
  533. })
  534. })
  535. }
  536. },
  537. getUnitInfo(val) {
  538. this.unitList = val
  539. },
  540. },
  541. }
  542. </script>
  543. <style scoped></style>