BaseFormYY.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. <template>
  2. <a-card :bordered="false" v-show="visible" class="card" :title="modalTitle">
  3. <a-form :form="form">
  4. <a-form-item v-show="false" >
  5. <a-input v-decorator="['id']" type="hidden"/>
  6. <a-input v-decorator="['storeId']" type="hidden"/>
  7. <a-input v-decorator="['pickId']" type="hidden"/>
  8. <a-input v-decorator="['outFlag']" type="hidden"/>
  9. </a-form-item>
  10. <a-row :gutter="24">
  11. <a-col :lg="12" :md="24" :sm="24">
  12. <a-form-item
  13. label="出库单号"
  14. :labelCol="BaseTool.Constant.labelCol"
  15. :wrapperCol="BaseTool.Constant.wrapperCol"
  16. >
  17. <a-input
  18. disabled
  19. v-decorator="['outNo', {rules: [{required: false, message: '出库单号不能为空'}]}]" />
  20. </a-form-item>
  21. </a-col>
  22. <!-- <a-col :lg="12" :md="24" :sm="24">
  23. <a-form-item
  24. label="领用/退货单号"
  25. :labelCol="BaseTool.Constant.labelCol"
  26. :wrapperCol="BaseTool.Constant.wrapperCol"
  27. >
  28. <a-input
  29. disabled
  30. style="width: 70%"
  31. v-decorator="['pickNo']"/>
  32. <a-button type="primary" style="width: 30%" @click="handleSparePickFormSelect">选择</a-button>
  33. </a-form-item>
  34. </a-col>
  35. <a-col :lg="12" :md="24" :sm="24">
  36. <a-form-item
  37. label="仓库"
  38. :labelCol="BaseTool.Constant.labelCol"
  39. :wrapperCol="BaseTool.Constant.wrapperCol"
  40. >
  41. <a-tree-select
  42. style="width: 100%"
  43. @change="handleStoreChange"
  44. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  45. :treeData="storeTreeDate"
  46. :treeNodeFilterProp="'title'"
  47. :showSearch="true"
  48. v-decorator="['storeId', {rules: [{required: false, message: '仓库不能为空'}]}]"
  49. placeholder="请选择"
  50. >
  51. </a-tree-select>
  52. </a-form-item>
  53. </a-col>-->
  54. <a-col :lg="12" :md="24" :sm="24">
  55. <a-form-item
  56. label="申请部门"
  57. :labelCol="BaseTool.Constant.labelCol"
  58. :wrapperCol="BaseTool.Constant.wrapperCol"
  59. >
  60. <a-tree-select
  61. style="width: 100%"
  62. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  63. :treeData="deptYYMap"
  64. v-decorator="['applyDept', {initValue: '09', rules: [{required: true, message: '申请部门不能为空'}]}]"
  65. placeholder="请选择"
  66. >
  67. </a-tree-select>
  68. <!-- <a-select @change="typeChange" v-decorator="['applyDept', {initValue: 1, rules: [{required: true, message: '申请部门不能为空'}]}]" placeholder="请选择">
  69. <a-select-option
  70. v-for="({label,value}) in deptYYMap"
  71. :key="value"
  72. :label="label"
  73. :value="value">{{ label }}
  74. </a-select-option>
  75. </a-select> -->
  76. </a-form-item>
  77. </a-col>
  78. <a-col :lg="12" :md="24" :sm="24">
  79. <a-form-item
  80. label="出库类型"
  81. :labelCol="BaseTool.Constant.labelCol"
  82. :wrapperCol="BaseTool.Constant.wrapperCol"
  83. >
  84. <a-select @change="typeChange" v-decorator="['type', {initValue: 1, rules: [{required: true, message: '出库类型不能为空'}]}]" placeholder="请选择">
  85. <a-select-option
  86. v-for="(label,value) in typeMap"
  87. :key="value"
  88. :label="label"
  89. :value="parseInt(value)">{{ label }}
  90. </a-select-option>
  91. </a-select>
  92. </a-form-item>
  93. </a-col>
  94. <!-- <a-col :lg="12" :md="24" :sm="24">
  95. <a-form-item
  96. label="操作人"
  97. :labelCol="BaseTool.Constant.labelCol"
  98. :wrapperCol="BaseTool.Constant.wrapperCol"
  99. >
  100. <a-select v-decorator="['userId']" placeholder="请选择">
  101. <a-select-option
  102. v-for="({userId, realName}) in userList"
  103. :key="userId"
  104. :label="realName"
  105. :value="userId">{{ realName }}
  106. </a-select-option>
  107. </a-select>
  108. </a-form-item>
  109. </a-col>-->
  110. <a-col :lg="12" :md="24" :sm="24">
  111. <a-form-item
  112. label="领用日期"
  113. :labelCol="BaseTool.Constant.labelCol"
  114. :wrapperCol="BaseTool.Constant.wrapperCol"
  115. >
  116. <a-date-picker
  117. style="width: 100%"
  118. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  119. v-decorator="['userTime', {rules: [{required: true, message: '操作时间不能为空'}]}]" />
  120. </a-form-item>
  121. </a-col>
  122. <a-col :lg="12" :md="24" :sm="24">
  123. <a-form-item
  124. label="成本归属"
  125. :labelCol="BaseTool.Constant.labelCol"
  126. :wrapperCol="BaseTool.Constant.wrapperCol"
  127. >
  128. <a-select v-decorator="['feeFrom', {rules: [{required: true, message: '成本归属不能为空'}]}]" placeholder="请选择">
  129. <a-select-option
  130. v-for="(label,value) in feeFromMap"
  131. :key="value"
  132. :label="label"
  133. :value="value">{{ label }}
  134. </a-select-option>
  135. </a-select>
  136. </a-form-item>
  137. </a-col>
  138. <!-- <a-tree-select-->
  139. <!-- style="width: 100%"-->
  140. <!-- :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"-->
  141. <!-- :treeData="treeData"-->
  142. <!-- :treeNodeFilterProp="'title'"-->
  143. <!-- :showSearch="true"-->
  144. <!-- v-decorator="['parentId', {rules: [{required: isShowParent, message: '上层设备类型不能为空'}]}]"-->
  145. <!-- placeholder="请选择"-->
  146. <!-- >-->
  147. <a-col :lg="12" :md="24" :sm="24">
  148. <a-form-item
  149. label="厂区"
  150. :labelCol="BaseTool.Constant.labelCol"
  151. :wrapperCol="BaseTool.Constant.wrapperCol"
  152. >
  153. <a-select v-model="tokenType" placeholder="请选择" @change="setTree">
  154. <a-select-option
  155. v-for="(label,value) in flagMap"
  156. :key="value"
  157. :label="label"
  158. :value="parseInt(value)">{{ label }}
  159. </a-select-option>
  160. </a-select>
  161. </a-form-item>
  162. </a-col>
  163. <a-col :lg="12" :md="24" :sm="24">
  164. <a-form-item
  165. label="用途备注"
  166. :labelCol="BaseTool.Constant.labelCol"
  167. :wrapperCol="BaseTool.Constant.wrapperCol"
  168. >
  169. <a-textarea
  170. :rows="4"
  171. v-decorator="['remark', {rules: [{required: false, message: '备注不能为空'}]}]"/>
  172. </a-form-item>
  173. </a-col>
  174. <a-col :lg="12" :md="24" :sm="24">
  175. <a-form-item
  176. label="项目:"
  177. :labelCol="BaseTool.Constant.labelCol"
  178. :wrapperCol="BaseTool.Constant.wrapperCol"
  179. >
  180. <a-select v-decorator="['projectId']" placeholder="请选择">
  181. <a-select-option
  182. v-for="{name,id} in treeData"
  183. :key="id"
  184. :label="name"
  185. :value="id">{{ name }}
  186. </a-select-option>
  187. </a-select>
  188. </a-form-item>
  189. <a-form-item
  190. label="部门"
  191. :labelCol="BaseTool.Constant.labelCol"
  192. :wrapperCol="BaseTool.Constant.wrapperCol"
  193. >
  194. <a-select v-decorator="['deptId', {rules: [{required: true, message: '部门不能为空'}]}]" placeholder="请选择">
  195. <a-select-option
  196. v-for="(label,value) in (tokenType===2?lyDeptMap:sdDeptMap)"
  197. :key="value"
  198. :label="label"
  199. :value="value">{{ label }}
  200. </a-select-option>
  201. </a-select>
  202. </a-form-item>
  203. </a-col>
  204. </a-row>
  205. </a-form>
  206. <title-divider title="备件明细" width="90px"></title-divider>
  207. <div class="table-operator" style="margin-bottom: 8px;">
  208. <a-button size="small" type="primary" @click="handleSpareStoreSelect">
  209. <a-icon type="plus"/>
  210. 添加
  211. </a-button>
  212. <a-button class="margin-left8" size="small" type="danger" @click="handleDel">
  213. <a-icon type="delete"/>
  214. 删除
  215. </a-button>
  216. </div>
  217. <a-table
  218. bordered
  219. :data-source="data"
  220. :columns="columns"
  221. tableLayout="auto"
  222. rowKey="autoId"
  223. :row-selection="rowSelection">
  224. <template slot="num" slot-scope="text, record">
  225. <div class="editable-cell-input-wrapper">
  226. <a-input :value="text" :id="record.autoId + ',num'" @change="$event => onQuantityChange($event, record.autoId, 'num')" />
  227. </div>
  228. </template>
  229. <template slot="remark" slot-scope="text, record">
  230. <div>
  231. <a-input v-model="record.remark" />
  232. </div>
  233. </template>
  234. <span slot="action" slot-scope="record">
  235. <template>
  236. <a @click="handleBaseFormForModifySelect(record)">修改</a>
  237. <a-divider type="vertical" />
  238. <a-popconfirm title="是否要删除该条数据?" @confirm="handleDelOne(record)">
  239. <a>删除</a>
  240. </a-popconfirm>
  241. </template>
  242. </span>
  243. </a-table>
  244. <a-row :gutter="48" >
  245. <a-col :md="48" :sm="48">
  246. <span class="table-page-search-submitButtons" style="float: right;margin-top: 10px">
  247. <a-button :loading="confirmLoading" type="primary" @click="save()">提交</a-button>
  248. <a-button style="margin-left: 8px" @click="handleCancel()">返回</a-button>
  249. </span>
  250. </a-col>
  251. </a-row>
  252. <spare-pick-form-select-modal ref="sparePickFormSelectModal" @selected="handleSparePickFormSelected"/>
  253. <spare-back-form-select-modal ref="spareBackFormSelectModal" @selected="handleSpareBackFormSelected"/>
  254. <spare-store-select-modal ref="spareStoreSelectModal" @selected="handleSpareStoreSelected"/>
  255. <detail-base-form ref="detailBaseForm" @selected="handleDetailSelected"/>
  256. <store-select-modal ref="storeSelectModal" @selected="handleStoreSelected"/>
  257. <base-form-for-modify ref="baseFormForModify" @selected="handleBaseFormForModifySelected"/>
  258. </a-card>
  259. </template>
  260. <script>
  261. import pick from 'lodash.pick'
  262. import { addOutStoreFormYY, updateOutStoreFormYY } from '@/api/store/outstoreform'
  263. import SparePickFormSelectModal from '@/views/store/sparepickform/modules/SparePickFormSelectModal'
  264. import SpareBackFormSelectModal from '@/views/store/sparebackform/modules/SpareBackFormSelectModal'
  265. import DetailBaseForm from './DetailBaseForm'
  266. import StoreSelectModal from '@/views/store/store/modules/StoreSelectModal'
  267. import SpareStoreSelectModal from '@/views/store/sparestore/modules/SpareStoreSelectModalYY'
  268. import BaseFormForModify from '@/views/store/outstoredetail/modules/BaseFormForModify'
  269. import BaseTool from '@/utils/tool'
  270. import { queryUsersByParentDeptNatureAll } from '@/api/upms/user'
  271. import { fetchStoreTree } from '@/api/store/store'
  272. import { getSbPositions } from '@/api/repair/application-form'
  273. import { fetchSbTypeTree } from '@/api/project/project'
  274. import { stringify } from 'qs'
  275. export default {
  276. name: 'BaseOutStoreFormYY',
  277. components: {
  278. DetailBaseForm,
  279. SparePickFormSelectModal,
  280. SpareBackFormSelectModal,
  281. SpareStoreSelectModal,
  282. StoreSelectModal,
  283. BaseFormForModify
  284. },
  285. data () {
  286. return {
  287. confirmLoading: false,
  288. modalTitle: null,
  289. form: this.$form.createForm(this),
  290. visible: false,
  291. maskClosable: false,
  292. outFlag: 1,
  293. tokenType: 1,
  294. model: {},
  295. sbPositionList: [],
  296. feeFromMap: {},
  297. lyDeptMap: {},
  298. flagMap: {},
  299. sdDeptMap: {},
  300. storeId: null,
  301. treeData: [],
  302. // 下拉框map
  303. typeMap: {},
  304. deptYYMap: {},
  305. // 表头
  306. columns: [
  307. {
  308. title: '序号',
  309. dataIndex: 'index',
  310. customRender: (text, record, index) => {
  311. return index + 1
  312. }
  313. },
  314. {
  315. title: '名称',
  316. dataIndex: 'spareName'
  317. },
  318. {
  319. title: '编号',
  320. dataIndex: 'no'
  321. },
  322. {
  323. title: '规格',
  324. dataIndex: 'ggxh'
  325. },
  326. {
  327. title: '批次',
  328. dataIndex: 'cbatch'
  329. },
  330. {
  331. title: '数量',
  332. dataIndex: 'num',
  333. width: 150,
  334. scopedSlots: { customRender: 'num' }
  335. },
  336. {
  337. title: '库存',
  338. dataIndex: 'storeNum',
  339. width: 150
  340. },
  341. {
  342. title: '单位',
  343. dataIndex: 'unit'
  344. },
  345. {
  346. title: '仓库',
  347. dataIndex: 'storeName'
  348. },
  349. {
  350. title: '货架号',
  351. dataIndex: 'storePosition'
  352. },
  353. /* {
  354. title: '备注',
  355. dataIndex: 'remark',
  356. width: 150,
  357. scopedSlots: { customRender: 'remark' }
  358. }, */
  359. {
  360. title: '操作',
  361. key: 'action',
  362. align: 'center',
  363. scopedSlots: { customRender: 'action' }
  364. }
  365. ],
  366. data: [],
  367. storeTreeDate: [],
  368. userList: {},
  369. user: this.$store.getters.userInfo,
  370. selectedRowKeys: [],
  371. selectedRows: [],
  372. options: {
  373. rowSelection: {
  374. selectedRowKeys: this.selectedRowKeys
  375. }
  376. },
  377. rowSelection: {
  378. onChange: (selectedRowKeys, selectedRows) => {
  379. this.selectedRowKeys = selectedRowKeys
  380. this.selectedRows = selectedRows
  381. }
  382. }
  383. }
  384. },
  385. props: {
  386. },
  387. created () {
  388. this.setTree()
  389. // 下拉框map
  390. this.getSbPositions()
  391. this.feeFromMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.FEE_FORM_TYPE)
  392. this.lyDeptMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.DEPT_TYPE_LY)
  393. this.sdDeptMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.DEPT_TYPE_SD)
  394. this.flagMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PROJECT_NEW_AND_OLD)
  395. console.log(this.lyDeptMap)
  396. console.log(this.sdDeptMap)
  397. this.deptYYMap = this.DictCache.getChildrenList(this.DictCache.TYPE.OUT_STORE_FORM_DEPT_CODE).map(item => {
  398. if (item.code === 'SBB') {
  399. item.children = this.DictCache.getChildrenList(this.DictCache.TYPE.SBB)
  400. }
  401. return item
  402. })
  403. console.log(1, this.deptYYMap, 1)
  404. // this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.OUT_STORE_FORM_TYPE)
  405. },
  406. methods: {
  407. base (record, model) {
  408. this.visible = true
  409. this.model = model
  410. this.outFlag = record.outFlag
  411. if (record.outFlag === 1) {
  412. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.OUT_STORE_FORM_TYPE)
  413. } else {
  414. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_BACK_FORM_TYPE)
  415. }
  416. const params = { deptId: this.user.companyId }
  417. params.nature = this.DictCache.VALUE.SYS_DEPT_NATURE.FEN_GONG_SI
  418. queryUsersByParentDeptNatureAll(params).then(res => {
  419. this.userList = res.data
  420. })
  421. fetchStoreTree().then(res => {
  422. this.storeTreeDate = res.data
  423. })
  424. // 如果是空标识添加
  425. if (this.BaseTool.Object.isBlank(record.id)) {
  426. this.modalTitle = '添加'
  427. this.data = []
  428. const { form: { setFieldsValue } } = this
  429. // 日期处理
  430. this.$nextTick(() => {
  431. setFieldsValue(Object.assign(pick(record, [
  432. 'outFlag'
  433. ]), pick(model, [
  434. 'sbCph'
  435. ]), {
  436. 'sbPosition': model.sbPosition.split('->')
  437. }))
  438. })
  439. return
  440. }
  441. this.modalTitle = '编辑'
  442. const { form: { setFieldsValue } } = this
  443. // 日期处理
  444. this.storeId = record.storeId
  445. this.$nextTick(() => {
  446. setFieldsValue(Object.assign(pick(record, [
  447. 'id',
  448. 'outNo',
  449. 'userId',
  450. 'applyDept',
  451. 'userTime',
  452. 'storeId',
  453. 'storeName',
  454. 'pickId',
  455. 'feeFrom',
  456. 'pickNo',
  457. 'type',
  458. 'remark'
  459. ])))
  460. })
  461. this.data = record.detailList
  462. },
  463. setTree () {
  464. fetchSbTypeTree({
  465. flag: this.tokenType,
  466. type: 2
  467. }).then((res) => {
  468. this.treeData = res.data
  469. })
  470. },
  471. save () {
  472. const { form: { validateFieldsAndScroll } } = this
  473. this.confirmLoading = true
  474. validateFieldsAndScroll((errors, values) => {
  475. if (errors) {
  476. this.confirmLoading = false
  477. return
  478. }
  479. if (this.data.length === 0) {
  480. this.$message.error('请添加出库详情')
  481. this.confirmLoading = false
  482. return
  483. }
  484. values.outFlag = this.outFlag
  485. values.detailList = this.data
  486. if (this.model != null) {
  487. values.pickId = this.model.id
  488. }
  489. values.oldOrNew = this.tokenType
  490. values.userTime = BaseTool.Date.formatter(values.userTime, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  491. // 日期处理
  492. if (this.BaseTool.String.isBlank(values.id)) {
  493. addOutStoreFormYY(values)
  494. .then(() => {
  495. this.handleCancel(values)
  496. }).catch(() => {
  497. this.confirmLoading = false
  498. })
  499. } else {
  500. updateOutStoreFormYY(values)
  501. .then(() => {
  502. this.handleCancel(values)
  503. }).catch(() => {
  504. this.confirmLoading = false
  505. })
  506. }
  507. })
  508. },
  509. loadData (selectedOptions) {
  510. console.log(selectedOptions)
  511. const targetOption = selectedOptions[selectedOptions.length - 1]
  512. targetOption.loading = true
  513. getSbPositions({ parentId: targetOption.id }).then(res => {
  514. targetOption.loading = false
  515. targetOption.children = res.data.map(item => {
  516. item = {
  517. label: item.name,
  518. value: item.name
  519. }
  520. return item
  521. })
  522. this.sbPositionList = [...this.sbPositionList]
  523. })
  524. },
  525. getSbPositions (parentId) {
  526. getSbPositions({ parentId }).then(res => {
  527. console.log(res)
  528. this.sbPositionList = res.data.map(item => {
  529. item = {
  530. label: item.name,
  531. value: item.name,
  532. id: item.id,
  533. isLeaf: false
  534. }
  535. return item
  536. })
  537. })
  538. },
  539. handleCancel (values) {
  540. this.visible = false
  541. this.confirmLoading = false
  542. this.form.resetFields()
  543. if (this.BaseTool.Object.isNotBlank(values)) {
  544. this.$emit('ok', values)
  545. } else {
  546. this.$emit('ok')
  547. }
  548. },
  549. typeChange (values) {
  550. this.type = values
  551. },
  552. handleStoreSelect () {
  553. this.$refs.storeSelectModal.base({}, { filter: -1 })
  554. },
  555. handleStoreSelected (record, keys, rows) {
  556. // 重新选择了仓库,则明细需要全部清空
  557. this.data = []
  558. const [ key ] = keys
  559. const [ row ] = rows
  560. const { form: { setFieldsValue } } = this
  561. this.storeId = key
  562. // 日期处理
  563. this.$nextTick(() => {
  564. setFieldsValue(Object.assign({
  565. 'storeId': key,
  566. 'storeName': row.name
  567. }))
  568. })
  569. },
  570. handleSparePickFormSelect () {
  571. if (this.type === 1) {
  572. this.$refs.sparePickFormSelectModal.base()
  573. } else {
  574. this.$refs.spareBackFormSelectModal.base()
  575. }
  576. },
  577. handleSparePickFormSelected (record, keys, rows) {
  578. const [ key ] = keys
  579. const [ row ] = rows
  580. const { form: { setFieldsValue } } = this
  581. // 日期处理
  582. setFieldsValue(Object.assign({
  583. 'pickId': key,
  584. 'pickNo': row.pickNo
  585. }))
  586. },
  587. handleSpareBackFormSelected (record, keys, rows) {
  588. const [ key ] = keys
  589. const [ row ] = rows
  590. const { form: { setFieldsValue } } = this
  591. // 日期处理
  592. setFieldsValue(Object.assign({
  593. 'pickId': key,
  594. 'pickNo': row.pickNo
  595. }))
  596. },
  597. handleDetailSelect () {
  598. if (this.storeId == null) {
  599. this.$message.error('请先选择仓库')
  600. return
  601. }
  602. this.$refs.detailBaseForm.base({ storeId: this.storeId })
  603. },
  604. handleDetailSelected (record) {
  605. const { data } = this
  606. data.push(record)
  607. },
  608. handleDel (id) {
  609. const data = [...this.data]
  610. if (this.selectedRowKeys.length === 0) {
  611. this.$message.error('请至少选择一条数据')
  612. return
  613. }
  614. this.data = data.filter(item => !this.selectedRowKeys.includes(item.id))
  615. },
  616. handleDelOne (record) {
  617. const data = [...this.data]
  618. this.data = data.filter(item => record.autoId !== item.autoId)
  619. },
  620. handleSpareStoreSelect () {
  621. this.$refs.spareStoreSelectModal.base({ tokenType: this.tokenType })
  622. },
  623. handleSpareStoreSelected (record, keys, rows) {
  624. console.log(rows)
  625. const { data } = this
  626. for (let i = 0; i < rows.length; i++) {
  627. let find = false
  628. for (let j = 0; j < data.length; j++) {
  629. if (rows[i].autoId === data[j].autoId) {
  630. find = true
  631. break
  632. }
  633. }
  634. if (!find) {
  635. const selectData = rows[i]
  636. selectData.storeNum = selectData.num
  637. selectData.num = 1
  638. data.push(selectData)
  639. }
  640. }
  641. },
  642. handleStoreChange (value) {
  643. this.storeId = value
  644. },
  645. handleBaseFormForModifySelect (record) {
  646. this.$refs.baseFormForModify.base(record)
  647. },
  648. handleBaseFormForModifySelected (values) {
  649. console.log('values' + values.id)
  650. const { data } = this
  651. for (let j = 0; j < data.length; j++) {
  652. if (values.id === data[j].id) {
  653. data[j].num = values.num
  654. data[j].totalPrice = values.totalPrice
  655. break
  656. }
  657. }
  658. },
  659. onQuantityChange (e, autoId, attr) {
  660. const value = e.target.value
  661. console.log(value)
  662. if (value !== 0 && !value) {
  663. return
  664. }
  665. const data = [...this.data]
  666. const target = data.find(item => item.autoId === autoId)
  667. if (this.outFlag === 1 && value > target.storeNum) {
  668. this.$message.error('领用数量不能大于库存数量')
  669. target[attr] = 1
  670. return
  671. }
  672. console.log('target: ' + target)
  673. if (target) {
  674. target[attr] = value
  675. this.data = data
  676. }
  677. },
  678. onTotalPriceChange (e, id, attr) {
  679. const value = e.target.value
  680. console.log(value)
  681. if (value !== 0 && !value) {
  682. return
  683. }
  684. const data = [...this.data]
  685. const target = data.find(item => item.id === id)
  686. console.log('target: ' + target)
  687. if (target) {
  688. target[attr] = value
  689. this.data = data
  690. }
  691. }
  692. }
  693. }
  694. </script>