RetailBackModal.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  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']"
  32. :disabled="!rowCanEdit"
  33. :dropdownMatchSelectWidth="false"
  34. showSearch
  35. optionFilterProp="children"
  36. >
  37. <div slot="dropdownRender" slot-scope="menu">
  38. <v-nodes :vnodes="menu" />
  39. <a-divider style="margin: 4px 0" />
  40. <div
  41. v-if="quickBtn.member"
  42. style="padding: 4px 8px; cursor: pointer"
  43. @mousedown="(e) => e.preventDefault()"
  44. @click="addMember"
  45. >
  46. <a-icon type="plus" /> 新增会员
  47. </div>
  48. </div>
  49. <a-select-option v-for="(item, index) in retailList" :key="index" :value="item.id">
  50. {{ item.supplier }}
  51. </a-select-option>
  52. </a-select>
  53. </a-form-item>
  54. </a-col>
  55. <a-col :lg="6" :md="12" :sm="24">
  56. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="单据日期">
  57. <j-date v-decorator="['operTime', validatorRules.operTime]" :show-time="true" />
  58. </a-form-item>
  59. </a-col>
  60. <a-col :lg="6" :md="12" :sm="24">
  61. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="单据编号">
  62. <a-input placeholder="请输入单据编号" v-decorator.trim="['number']" />
  63. </a-form-item>
  64. </a-col>
  65. <a-col :lg="6" :md="12" :sm="24">
  66. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="关联单据">
  67. <a-input-search
  68. placeholder="请选择关联单据"
  69. v-decorator="['linkNumber']"
  70. @search="onSearchLinkNumber"
  71. :readOnly="true"
  72. />
  73. </a-form-item>
  74. </a-col>
  75. </a-row>
  76. <a-row class="form-row" :gutter="24">
  77. <a-col :lg="18" :md="12" :sm="24">
  78. <j-editable-table
  79. id="billModal"
  80. :ref="refKeys[0]"
  81. :loading="materialTable.loading"
  82. :columns="materialTable.columns"
  83. :dataSource="materialTable.dataSource"
  84. :minWidth="minWidth"
  85. :maxHeight="300"
  86. :rowNumber="false"
  87. :rowSelection="rowCanEdit"
  88. :actionButton="rowCanEdit"
  89. :dragSortAndNumber="rowCanEdit"
  90. @valueChange="onValueChange"
  91. @added="onAdded"
  92. @deleted="onDeleted"
  93. >
  94. <template #buttonAfter>
  95. <a-row
  96. v-if="rowCanEdit"
  97. :gutter="24"
  98. style="float: left; padding-bottom: 5px"
  99. data-step="4"
  100. data-title="扫码录入"
  101. data-intro="此功能支持扫码枪扫描商品条码进行录入"
  102. >
  103. <a-col v-if="scanStatus" :md="6" :sm="24">
  104. <a-button @click="scanEnter" style="margin-right: 8px">扫码录入</a-button>
  105. </a-col>
  106. <a-col v-if="!scanStatus" :md="16" :sm="24" style="padding: 0 6px 0 12px">
  107. <a-input
  108. placeholder="请扫描商品条码并回车"
  109. v-model="scanBarCode"
  110. @pressEnter="scanPressEnter"
  111. ref="scanBarCode"
  112. />
  113. </a-col>
  114. <a-col v-if="!scanStatus" :md="6" :sm="24" style="padding: 0px 18px 0 0">
  115. <a-button @click="stopScan" style="margin-right: 8px">收起扫码</a-button>
  116. </a-col>
  117. </a-row>
  118. </template>
  119. <template #depotBatchSet>
  120. <a-icon type="down" @click="handleBatchSetDepot" />
  121. </template>
  122. <template #depotAdd>
  123. <a-divider v-if="quickBtn.depot" style="margin: 4px 0" />
  124. <div v-if="quickBtn.depot" style="padding: 4px 8px; cursor: pointer" @click="addDepot">
  125. <a-icon type="plus" /> 新增仓库
  126. </div>
  127. </template>
  128. </j-editable-table>
  129. <a-row class="form-row" :gutter="24">
  130. <a-col :lg="24" :md="24" :sm="24">
  131. <a-form-item :labelCol="labelCol" :wrapperCol="{ xs: { span: 24 }, sm: { span: 24 } }" label="">
  132. <a-textarea :rows="1" placeholder="请输入备注" v-decorator="['remark']" style="margin-top: 8px" />
  133. </a-form-item>
  134. </a-col>
  135. </a-row>
  136. <a-row class="form-row" :gutter="24">
  137. <a-col :lg="6" :md="12" :sm="24">
  138. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="附件">
  139. <j-upload v-model="fileList" bizPath="bill"></j-upload>
  140. </a-form-item>
  141. </a-col>
  142. </a-row>
  143. </a-col>
  144. <div class="sign">
  145. <a-col :lg="6" :md="12" :sm="24">
  146. <a-row class="form-row" :gutter="24">
  147. <a-col :lg="24" :md="6" :sm="6"><br /><br /></a-col>
  148. <a-col :lg="24" :md="6" :sm="6">
  149. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol">
  150. <span slot="label" style="font-size: 20px; line-height: 20px">单据金额</span>
  151. <a-input v-decorator.trim="['changeAmount']" :style="{ color: 'purple' }" :readOnly="true" />
  152. </a-form-item>
  153. </a-col>
  154. <a-col :lg="24" :md="6" :sm="6">
  155. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol">
  156. <span slot="label" style="font-size: 20px; line-height: 20px">付款金额</span>
  157. <a-input
  158. v-decorator.trim="['getAmount']"
  159. :style="{ color: 'red' }"
  160. defaultValue="0"
  161. @change="onChangeGetAmount"
  162. />
  163. </a-form-item>
  164. </a-col>
  165. <a-col :lg="24" :md="6" :sm="6">
  166. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol">
  167. <span slot="label" style="font-size: 20px; line-height: 20px">找零</span>
  168. <a-input
  169. v-decorator.trim="['backAmount']"
  170. :style="{ color: 'green' }"
  171. :readOnly="true"
  172. defaultValue="0"
  173. />
  174. </a-form-item>
  175. </a-col>
  176. <a-col :lg="24" :md="6" :sm="6">
  177. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol">
  178. <span slot="label" style="font-size: 20px; line-height: 20px">付款账户</span>
  179. <a-select
  180. placeholder="请选择付款账户"
  181. style="font-size: 20px"
  182. v-decorator="['accountId', validatorRules.accountId]"
  183. :dropdownMatchSelectWidth="false"
  184. >
  185. <div slot="dropdownRender" slot-scope="menu">
  186. <v-nodes :vnodes="menu" />
  187. <a-divider style="margin: 4px 0" />
  188. <div
  189. v-if="quickBtn.account"
  190. style="padding: 4px 8px; cursor: pointer"
  191. @mousedown="(e) => e.preventDefault()"
  192. @click="addAccount"
  193. >
  194. <a-icon type="plus" /> 新增结算账户
  195. </div>
  196. </div>
  197. <a-select-option v-for="(item, index) in accountList" :key="index" :value="item.id">
  198. {{ item.name }}
  199. </a-select-option>
  200. </a-select>
  201. </a-form-item>
  202. </a-col>
  203. </a-row>
  204. </a-col>
  205. </div>
  206. </a-row>
  207. </a-form>
  208. </a-spin>
  209. <link-bill-list ref="linkBillList" @ok="linkBillListOk"></link-bill-list>
  210. <member-modal ref="memberModalForm" @ok="memberModalFormOk"></member-modal>
  211. <depot-modal ref="depotModalForm" @ok="depotModalFormOk"></depot-modal>
  212. <account-modal ref="accountModalForm" @ok="accountModalFormOk"></account-modal>
  213. <batch-set-depot ref="batchSetDepotModalForm" @ok="batchSetDepotModalFormOk"></batch-set-depot>
  214. <workflow-iframe ref="modalWorkflow" @ok="workflowModalFormOk"></workflow-iframe>
  215. <bill-print-iframe ref="modalPrint"></bill-print-iframe>
  216. </j-modal>
  217. </template>
  218. <script>
  219. import pick from 'lodash.pick'
  220. import LinkBillList from '../dialog/LinkBillList'
  221. import MemberModal from '../../system/modules/MemberModal'
  222. import DepotModal from '../../system/modules/DepotModal'
  223. import AccountModal from '../../system/modules/AccountModal'
  224. import BatchSetDepot from '../dialog/BatchSetDepot'
  225. import WorkflowIframe from '@/components/tools/WorkflowIframe'
  226. import BillPrintIframe from '../dialog/BillPrintIframe'
  227. import { FormTypes } from '@/utils/JEditableTableUtil'
  228. import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
  229. import { BillModalMixin } from '../mixins/BillModalMixin'
  230. import { getMpListShort } from '@/utils/util'
  231. import { getAccount } from '@/api/api'
  232. import { getAction } from '@/api/manage'
  233. import JUpload from '@/components/jeecg/JUpload'
  234. import JDate from '@/components/jeecg/JDate'
  235. import Vue from 'vue'
  236. export default {
  237. name: 'RetailBackModal',
  238. mixins: [JEditableTableMixin, BillModalMixin],
  239. components: {
  240. LinkBillList,
  241. MemberModal,
  242. DepotModal,
  243. AccountModal,
  244. BatchSetDepot,
  245. WorkflowIframe,
  246. BillPrintIframe,
  247. JUpload,
  248. JDate,
  249. VNodes: {
  250. functional: true,
  251. render: (h, ctx) => ctx.props.vnodes,
  252. },
  253. },
  254. data() {
  255. return {
  256. title: '操作',
  257. width: '1600px',
  258. moreStatus: false,
  259. // 新增时子表默认添加几行空数据
  260. addDefaultRowNum: 1,
  261. visible: false,
  262. operTimeStr: '',
  263. prefixNo: 'LSTH',
  264. fileList: [],
  265. minWidth: 1100,
  266. rowCanEdit: true,
  267. model: {},
  268. labelCol: {
  269. xs: { span: 24 },
  270. sm: { span: 8 },
  271. },
  272. wrapperCol: {
  273. xs: { span: 24 },
  274. sm: { span: 16 },
  275. },
  276. refKeys: ['materialDataTable'],
  277. activeKey: 'materialDataTable',
  278. materialTable: {
  279. loading: false,
  280. dataSource: [],
  281. columns: [
  282. {
  283. title: '仓库名称',
  284. key: 'depotId',
  285. width: '10%',
  286. type: FormTypes.select,
  287. placeholder: '请选择${title}',
  288. options: [],
  289. allowSearch: true,
  290. validateRules: [{ required: true, message: '${title}不能为空' }],
  291. },
  292. {
  293. title: '条码',
  294. key: 'barCode',
  295. width: '16%',
  296. type: FormTypes.popupJsh,
  297. kind: 'material',
  298. multi: true,
  299. validateRules: [{ required: true, message: '${title}不能为空' }],
  300. },
  301. { title: '名称', key: 'name', width: '12%', type: FormTypes.normal },
  302. { title: '规格', key: 'standard', width: '10%', type: FormTypes.normal },
  303. { title: '型号', key: 'model', width: '10%', type: FormTypes.normal },
  304. { title: '颜色', key: 'color', width: '5%', type: FormTypes.normal },
  305. { title: '品牌', key: 'brand', width: '6%', type: FormTypes.normal },
  306. { title: '制造商', key: 'mfrs', width: '6%', type: FormTypes.normal },
  307. { title: '扩展信息', key: 'materialOther', width: '7%', type: FormTypes.normal },
  308. { title: '库存', key: 'stock', width: '5%', type: FormTypes.normal },
  309. { title: '单位', key: 'unit', width: '5%', type: FormTypes.normal },
  310. { title: '序列号', key: 'snList', width: '12%', type: FormTypes.popupJsh, kind: 'snAdd', multi: true },
  311. { title: '批号', key: 'batchNumber', width: '8%', type: FormTypes.input },
  312. { title: '有效期', key: 'expirationDate', width: '9%', type: FormTypes.date },
  313. { title: '多属性', key: 'sku', width: '9%', type: FormTypes.normal },
  314. { title: '原数量', key: 'preNumber', width: '6%', type: FormTypes.normal },
  315. { title: '已退货', key: 'finishNumber', width: '6%', type: FormTypes.normal },
  316. {
  317. title: '数量',
  318. key: 'operNumber',
  319. width: '6%',
  320. type: FormTypes.inputNumber,
  321. statistics: true,
  322. validateRules: [{ required: true, message: '${title}不能为空' }],
  323. },
  324. { title: '单价', key: 'unitPrice', width: '6%', type: FormTypes.inputNumber },
  325. { title: '金额', key: 'allPrice', width: '6%', type: FormTypes.inputNumber, statistics: true },
  326. { title: '备注', key: 'remark', width: '7%', type: FormTypes.input },
  327. { title: '关联id', key: 'linkId', width: '5%', type: FormTypes.hidden },
  328. ],
  329. },
  330. confirmLoading: false,
  331. validatorRules: {
  332. operTime: {
  333. rules: [{ required: true, message: '请输入单据日期!' }],
  334. },
  335. accountId: {
  336. rules: [{ required: true, message: '请选择结算账户!' }],
  337. },
  338. },
  339. url: {
  340. add: '/depotHead/addDepotHeadAndDetail',
  341. edit: '/depotHead/updateDepotHeadAndDetail',
  342. detailList: '/depotItem/getDetailList',
  343. },
  344. }
  345. },
  346. created() {
  347. let realScreenWidth = window.screen.width
  348. this.minWidth = realScreenWidth < 1500 ? 800 : 1100
  349. },
  350. methods: {
  351. //调用完edit()方法之后会自动调用此方法
  352. editAfter() {
  353. this.billStatus = '0'
  354. this.rowCanEdit = true
  355. this.materialTable.columns[1].type = FormTypes.popupJsh
  356. this.changeColumnHide()
  357. this.changeFormTypes(this.materialTable.columns, 'snList', 0)
  358. this.changeFormTypes(this.materialTable.columns, 'batchNumber', 0)
  359. this.changeFormTypes(this.materialTable.columns, 'expirationDate', 0)
  360. this.changeFormTypes(this.materialTable.columns, 'preNumber', 0)
  361. this.changeFormTypes(this.materialTable.columns, 'finishNumber', 0)
  362. if (this.action === 'add') {
  363. this.addInit(this.prefixNo)
  364. this.fileList = []
  365. this.$nextTick(() => {
  366. this.form.setFieldsValue({ getAmount: 0, backAmount: 0 })
  367. })
  368. } else {
  369. if (this.model.linkNumber) {
  370. this.rowCanEdit = false
  371. this.materialTable.columns[1].type = FormTypes.normal
  372. }
  373. this.model.operTime = this.model.operTimeStr
  374. if (this.model.backAmount) {
  375. this.model.getAmount = (this.model.changeAmount + this.model.backAmount).toFixed(2)
  376. } else {
  377. this.model.getAmount = this.model.changeAmount
  378. }
  379. this.fileList = this.model.fileName
  380. this.$nextTick(() => {
  381. this.form.setFieldsValue(
  382. pick(
  383. this.model,
  384. 'organId',
  385. 'operTime',
  386. 'number',
  387. 'linkNumber',
  388. 'remark',
  389. 'discount',
  390. 'discountMoney',
  391. 'discountLastMoney',
  392. 'otherMoney',
  393. 'accountId',
  394. 'changeAmount',
  395. 'getAmount',
  396. 'backAmount'
  397. )
  398. )
  399. })
  400. // 加载子表数据
  401. let params = {
  402. headerId: this.model.id,
  403. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  404. linkType: 'basic',
  405. }
  406. let url = this.readOnly ? this.url.detailList : this.url.detailList
  407. this.requestSubTableData(url, params, this.materialTable)
  408. }
  409. //复制新增单据-初始化单号和日期
  410. if (this.action === 'copyAdd') {
  411. this.model.id = ''
  412. this.model.tenantId = ''
  413. this.copyAddInit(this.prefixNo)
  414. }
  415. this.initSystemConfig()
  416. this.initRetail(0)
  417. this.initDepot()
  418. this.initAccount(0)
  419. this.initPlatform()
  420. this.initQuickBtn()
  421. },
  422. //提交单据时整理成formData
  423. classifyIntoFormData(allValues) {
  424. let totalPrice = 0
  425. let billMain = Object.assign(this.model, allValues.formValue)
  426. let detailArr = allValues.tablesValue[0].values
  427. billMain.type = '入库'
  428. billMain.subType = '零售退货'
  429. for (let item of detailArr) {
  430. totalPrice += item.allPrice - 0
  431. }
  432. billMain.totalPrice = 0 - totalPrice
  433. billMain.changeAmount = 0 - billMain.changeAmount
  434. if (this.fileList && this.fileList.length > 0) {
  435. billMain.fileName = this.fileList
  436. } else {
  437. billMain.fileName = ''
  438. }
  439. if (this.model.id) {
  440. billMain.id = this.model.id
  441. }
  442. billMain.status = this.billStatus
  443. return {
  444. info: JSON.stringify(billMain),
  445. rows: JSON.stringify(detailArr),
  446. }
  447. },
  448. initAccount(isChecked) {
  449. getAccount({}).then((res) => {
  450. if (res && res.code === 200) {
  451. this.accountList = res.data.accountList
  452. if (isChecked && this.accountList.length > 0) {
  453. this.form.setFieldsValue({ accountId: this.accountList[0].id })
  454. }
  455. }
  456. })
  457. },
  458. //改变实收金额、收款金额的值
  459. autoChangePrice(target) {
  460. let allLastMoney = target.statisticsColumns.allPrice
  461. this.$nextTick(() => {
  462. this.form.setFieldsValue({ changeAmount: allLastMoney, getAmount: allLastMoney, backAmount: 0 })
  463. })
  464. },
  465. //改变收款金额
  466. onChangeGetAmount(e) {
  467. const value = e.target.value
  468. let changeAmount = this.form.getFieldValue('changeAmount') - 0
  469. let backAmount = (value - changeAmount).toFixed(2) - 0
  470. this.$nextTick(() => {
  471. this.form.setFieldsValue({ backAmount: backAmount })
  472. })
  473. },
  474. onSearchLinkNumber() {
  475. this.$refs.linkBillList.show('出库', '零售', '会员', '1')
  476. this.$refs.linkBillList.title = '请选择零售出库'
  477. },
  478. linkBillListOk(selectBillDetailRows, linkNumber, organId, discountMoney, deposit, remark) {
  479. this.rowCanEdit = false
  480. this.materialTable.columns[1].type = FormTypes.normal
  481. this.changeFormTypes(this.materialTable.columns, 'preNumber', 1)
  482. this.changeFormTypes(this.materialTable.columns, 'finishNumber', 1)
  483. if (selectBillDetailRows && selectBillDetailRows.length > 0) {
  484. let listEx = []
  485. let allTaxLastMoney = 0
  486. for (let j = 0; j < selectBillDetailRows.length; j++) {
  487. let info = selectBillDetailRows[j]
  488. info.linkId = info.id
  489. allTaxLastMoney += info.allPrice
  490. listEx.push(info)
  491. this.changeColumnShow(info)
  492. }
  493. this.materialTable.dataSource = listEx
  494. ///给优惠后金额重新赋值
  495. allTaxLastMoney = allTaxLastMoney ? allTaxLastMoney : 0
  496. let discountLastMoney = allTaxLastMoney.toFixed(2) - 0
  497. this.$nextTick(() => {
  498. this.form.setFieldsValue({
  499. organId: organId,
  500. linkNumber: linkNumber,
  501. getAmount: discountLastMoney,
  502. changeAmount: discountLastMoney,
  503. backAmount: 0,
  504. remark: remark,
  505. })
  506. })
  507. }
  508. },
  509. },
  510. }
  511. </script>
  512. <style scoped>
  513. .sign .ant-input {
  514. font-size: 30px;
  515. font-weight: bolder;
  516. text-align: center;
  517. border-left-width: 0px !important;
  518. border-top-width: 0px !important;
  519. border-right-width: 0px !important;
  520. }
  521. </style>