OtherInModal.vue 19 KB

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