edit.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. <template>
  2. <div class="bulkWarehousingOrderEdit-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 内容 -->
  5. <a-page-header :ghost="false" :backIcon="false" class="bulkWarehousingOrderEdit-cont" >
  6. <!-- 自定义的二级文字标题 -->
  7. <template slot="subTitle">
  8. <a id="bulkWarehousingOrderEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  9. <p style=" display: inline-block;margin: 0 0 0 60px;color: #000;font-size: 16px;font-weight: 600;">单号:{{ (basicInfoData&&basicInfoData.sparePartsPurchaseNo) || '' }}</p>
  10. </template>
  11. <!-- 操作区,位于 title 行的行尾 -->
  12. <template slot="extra" v-if="$hasPermissions('B_bulkWarehousingOrder_print')">
  13. <Print :disabled="chooseLoadDataSource.length==0" :showExport="false" @handlePrint="handlePrint"></Print>
  14. </template>
  15. </a-page-header>
  16. <!-- 基础信息 -->
  17. <a-card size="small" :bordered="false" class="bulkWarehousingOrderEdit-cont">
  18. <a-collapse :activeKey="['1']">
  19. <a-collapse-panel key="1">
  20. <template slot="header">
  21. 基础信息
  22. </template>
  23. <a-descriptions :column="3">
  24. <a-descriptions-item label="供应商">{{ (basicInfoData&&basicInfoData.supplierName) || '--' }}</a-descriptions-item>
  25. <a-descriptions-item label="散件入库类型">{{ (basicInfoData&&basicInfoData.sparePartsTypeName) || '--' }}</a-descriptions-item>
  26. <a-descriptions-item label="备注">{{ (basicInfoData&&basicInfoData.remarks) || '--' }}</a-descriptions-item>
  27. </a-descriptions>
  28. </a-collapse-panel>
  29. </a-collapse>
  30. </a-card>
  31. <!-- 选择产品 -->
  32. <a-card size="small" :bordered="false" class="bulkWarehousingOrderEdit-cont">
  33. <a-collapse :activeKey="['1']">
  34. <a-collapse-panel key="1">
  35. <template slot="header">
  36. 选择产品<span class="sub-title">①输入查询条件--->②查找到需要入库的配件--->③录入成本价、数量、仓库、仓位--->④点击“添加”</span>
  37. </template>
  38. <!-- 选择产品 -->
  39. <div>
  40. <!-- 搜索条件 -->
  41. <div class="table-page-search-wrapper">
  42. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  43. <a-row :gutter="15">
  44. <a-col :md="6" :sm="24">
  45. <a-form-item label="关键词">
  46. <a-input id="bulkWarehousingOrderEdit-queryWord" v-model.trim="queryParam.queryWord" allowClear placeholder="产品名称/产品编码/原厂编码"/>
  47. </a-form-item>
  48. </a-col>
  49. <a-col :md="6" :sm="24">
  50. <a-form-item label="产品品牌">
  51. <ProductBrand id="bulkWarehousingOrderEdit-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  52. </a-form-item>
  53. </a-col>
  54. <a-col :md="6" :sm="24">
  55. <a-form-item label="产品分类">
  56. <ProductType id="productInfoList-productType" @change="changeProductType" v-model="productType"></ProductType>
  57. </a-form-item>
  58. </a-col>
  59. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  60. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="bulkWarehousingOrderEdit-refresh">查询</a-button>
  61. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="bulkWarehousingOrderEdit-reset">重置</a-button>
  62. </a-col>
  63. </a-row>
  64. </a-form>
  65. </div>
  66. <!-- 列表 -->
  67. <s-table
  68. class="sTable"
  69. ref="table"
  70. size="small"
  71. :rowKey="(record) => record.id"
  72. :columns="columns"
  73. :customRow="handleClickRow"
  74. :data="loadData"
  75. :defaultLoadData="false"
  76. :scroll="{ y: 300 }"
  77. bordered>
  78. <!-- 成本价 -->
  79. <template slot="putCost" slot-scope="text, record">
  80. <a-input-number
  81. size="small"
  82. id="bulkWarehousingOrderEdit-putCost"
  83. v-model="record.putCost"
  84. :precision="2"
  85. :min="0"
  86. :max="999999"
  87. placeholder="请输入"
  88. style="width: 100%;" />
  89. </template>
  90. <!-- 数量 -->
  91. <template slot="putQty" slot-scope="text, record">
  92. <a-input-number
  93. size="small"
  94. id="bulkWarehousingOrderEdit-putQty"
  95. v-model="record.putQty"
  96. :precision="0"
  97. :min="1"
  98. :max="999999"
  99. placeholder="请输入"
  100. style="width: 100%;" />
  101. </template>
  102. <!-- 仓库仓位 -->
  103. <template slot="warehouse" slot-scope="text, record, index">
  104. <a-cascader
  105. size="small"
  106. @change="e => changeWarehouseCascade(e, record, index, 'dealerProduct')"
  107. v-model="record.warehouseCascade"
  108. expand-trigger="hover"
  109. :allowClear="false"
  110. :options="warehouseCascadeData"
  111. :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
  112. id="bulkWarehousingOrderEdit-warehouseCascade"
  113. placeholder="请选择仓库仓位"
  114. style="width: 100%;" />
  115. </template>
  116. <!-- 操作 -->
  117. <template slot="action" slot-scope="text, record">
  118. <a-button size="small" type="primary" class="button-primary" @click="handleAdd(record)" id="bulkWarehousingOrderEdit-add-btn">添加</a-button>
  119. </template>
  120. </s-table>
  121. </div>
  122. </a-collapse-panel>
  123. </a-collapse>
  124. </a-card>
  125. <!-- 已选产品 -->
  126. <a-card size="small" :bordered="false" class="bulkWarehousingOrderEdit-cont">
  127. <a-collapse :activeKey="['1']">
  128. <a-collapse-panel key="1">
  129. <template slot="header">
  130. 已选产品
  131. </template>
  132. <!-- 已选产品 -->
  133. <div>
  134. <!-- 总计 -->
  135. <a-alert type="info" style="margin-bottom:10px">
  136. <div slot="message">
  137. 总款数 <strong>{{ (productTotal&&(productTotal.productTotalCategory || productTotal.productTotalCategory==0)) ? productTotal.productTotalCategory : '--' }}</strong> ,
  138. 总数量 <strong>{{ (productTotal&&(productTotal.productTotalQty || productTotal.productTotalQty==0)) ? productTotal.productTotalQty : '--' }}</strong> ,
  139. 总成本 <strong>{{ (productTotal&&(productTotal.productTotalCost || productTotal.productTotalCost==0)) ? '¥'+productTotal.productTotalCost : '--' }}</strong>
  140. </div>
  141. </a-alert>
  142. <!-- 列表 -->
  143. <s-table
  144. class="sTable"
  145. ref="chooseTable"
  146. size="small"
  147. :rowKey="(record) => record.id"
  148. :columns="chooseColumns"
  149. :data="chooseLoadData"
  150. :defaultLoadData="false"
  151. :scroll="{ y: 300 }"
  152. bordered>
  153. <!-- 成本价 -->
  154. <template slot="putCost" slot-scope="text, record">
  155. <a-input-number
  156. size="small"
  157. id="bulkWarehousingOrderEdit-choose-putCost"
  158. v-model="record.putCost"
  159. :precision="2"
  160. :min="0"
  161. :max="999999"
  162. placeholder="请输入"
  163. @blur="e => putCostBlur(e.target.value, record)"
  164. style="width: 100%;" />
  165. </template>
  166. <!-- 数量 -->
  167. <template slot="putQty" slot-scope="text, record">
  168. <a-input-number
  169. size="small"
  170. id="bulkWarehousingOrderEdit-choose-putQty"
  171. v-model="record.putQty"
  172. :precision="0"
  173. :min="1"
  174. :max="999999"
  175. placeholder="请输入"
  176. @blur="e => putQtyBlur(e.target.value, record)"
  177. style="width: 100%;" />
  178. </template>
  179. <!-- 仓库仓位 -->
  180. <template slot="warehouse" slot-scope="text, record, index">
  181. <a-cascader
  182. size="small"
  183. @change="e => changeWarehouseCascade(e, record, index, 'sparePartsPurDetail')"
  184. v-model="record.warehouseCascade"
  185. expand-trigger="hover"
  186. :allowClear="false"
  187. :options="warehouseCascadeData"
  188. :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
  189. id="bulkWarehousingOrderEdit-choose-warehouseCascade"
  190. placeholder="请选择仓库仓位"
  191. style="width: 100%;" />
  192. </template>
  193. <!-- 操作 -->
  194. <template slot="action" slot-scope="text, record">
  195. <a-button size="small" type="primary" class="button-error" @click="handleDel(record)" id="bulkWarehousingOrderEdit-del-btn">删除</a-button>
  196. </template>
  197. </s-table>
  198. </div>
  199. </a-collapse-panel>
  200. </a-collapse>
  201. </a-card>
  202. </a-spin>
  203. <div class="affix-cont">
  204. <a-button
  205. type="primary"
  206. id="bulkWarehousingOrderEdit-submit"
  207. size="large"
  208. :disabled="spinning"
  209. class="button-primary"
  210. @click="handleSubmit"
  211. style="padding: 0 60px;">提交</a-button>
  212. </div>
  213. <!-- 选择基本信息弹框 -->
  214. <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  215. </div>
  216. </template>
  217. <script>
  218. import { commonMixin } from '@/utils/mixin'
  219. import { STable, VSelect } from '@/components'
  220. import basicInfoModal from './basicInfoModal.vue'
  221. import { getOperationalPrecision } from '@/libs/tools.js'
  222. import { sparePartsPurDetail, sparePartsPurDetailList, sparePartsPurDetailCount, sparePartsPurDetailSave, sparePartsPurDetailDel, sparePartsPurSubmit, sparePartsPurDetailPrint } from '@/api/sparePartsPur'
  223. import { bulkProductList } from '@/api/dealerProduct'
  224. import { warehouseCascadeList } from '@/api/warehouse'
  225. import ProductType from '../../common/productType.js'
  226. import ProductBrand from '../../common/productBrand.js'
  227. import Print from '@/views/common/print.vue'
  228. import { hdPrint } from '@/libs/JGPrint'
  229. export default {
  230. name: 'BulkWarehousingEdit',
  231. components: { STable, VSelect, basicInfoModal, Print, ProductType, ProductBrand },
  232. mixins: [commonMixin],
  233. data () {
  234. return {
  235. spinning: false,
  236. loading: false,
  237. chooseLoading: false,
  238. queryParam: {
  239. queryWord: '',
  240. productBrandSn: undefined,
  241. productTypeSn1: undefined,
  242. productTypeSn2: undefined,
  243. productTypeSn3: undefined
  244. },
  245. productType: [],
  246. warehouseCascadeData: [], // 仓库仓位
  247. disabled: false, // 查询、重置按钮是否可操作
  248. // 表头
  249. columns: [
  250. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  251. { title: '产品编码', dataIndex: 'code', width: '16%', align: 'left', sorter: true, customRender: function (text) { return text || '--' } },
  252. { title: '产品名称', dataIndex: 'name', width: '16%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  253. { title: '原厂编码', dataIndex: 'origCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  254. { title: '产品品牌', dataIndex: 'productBrandName', width: '10%', align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  255. { title: '单位', dataIndex: 'unit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  256. { title: '成本价', scopedSlots: { customRender: 'putCost' }, width: '7%', align: 'center' },
  257. { title: '数量', scopedSlots: { customRender: 'putQty' }, width: '7%', align: 'center' },
  258. { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: '13%', align: 'center' },
  259. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  260. ],
  261. // 加载数据方法 必须为 Promise 对象
  262. loadData: parameter => {
  263. this.disabled = true
  264. parameter.sortAlias = 'dp'
  265. const params = Object.assign(parameter, this.queryParam, { supplierSn: this.$route.params.supplierSn })
  266. params.enabledFlag = 1
  267. return bulkProductList(params).then(res => {
  268. const data = res.data
  269. const no = (data.pageNo - 1) * data.pageSize
  270. for (var i = 0; i < data.list.length; i++) {
  271. data.list[i].no = no + i + 1
  272. data.list[i].putCost = data.list[i].purchasePrice || ''
  273. if (this.defaultWarehouseCascade.length > 0) {
  274. data.list[i].warehouseCascade = this.defaultWarehouseCascade
  275. data.list[i].warehouseSn = this.defaultWarehouseCascade[0]
  276. data.list[i].warehouseLocationSn = this.defaultWarehouseCascade[1]
  277. } else {
  278. data.list[i].warehouseCascade = undefined
  279. }
  280. }
  281. this.loadDataSource = data.list
  282. this.disabled = false
  283. return data
  284. })
  285. },
  286. // 表头
  287. chooseColumns: [
  288. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  289. { title: '产品编码', dataIndex: 'productCode', width: '14%', align: 'left', customRender: function (text) { return text || '--' }, sorter: true },
  290. { title: '产品名称', dataIndex: 'productName', width: '14%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  291. { title: '原厂编码', dataIndex: 'productOrigCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  292. { title: '产品品牌', dataIndex: 'brandName', width: '10%', align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  293. { title: '单位', dataIndex: 'productUnit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  294. { title: '成本价', scopedSlots: { customRender: 'putCost' }, width: '7%', align: 'center' },
  295. { title: '数量', scopedSlots: { customRender: 'putQty' }, width: '7%', align: 'center' },
  296. { title: '成本小计', dataIndex: 'costSubtotal', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  297. { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: '13%', align: 'center' },
  298. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  299. ],
  300. // 加载数据方法 必须为 Promise 对象
  301. chooseLoadData: parameter => {
  302. // 排序
  303. if (parameter.sortField == 'brandName') {
  304. parameter.sortField = 'productBrandName'
  305. parameter.sortAlias = 'dp'
  306. }
  307. if (parameter.sortField == 'productName') {
  308. parameter.sortField = 'productCode'
  309. parameter.sortAlias = 'sppd'
  310. }
  311. const params = Object.assign(parameter, { sparePartsPurchaseSn: this.$route.params.sn })
  312. return sparePartsPurDetailList(params).then(res => {
  313. this.getDetailCount(params)
  314. const data = res.data
  315. const no = (data.pageNo - 1) * data.pageSize
  316. for (var i = 0; i < data.list.length; i++) {
  317. data.list[i].no = no + i + 1
  318. data.list[i].putCostBackups = data.list[i].putCost
  319. data.list[i].putQtyBackups = data.list[i].putQty
  320. const warehouseSn = data.list[i].warehouseSn || undefined
  321. const warehouseLocationSn = data.list[i].warehouseLocationSn || undefined
  322. if (warehouseSn || warehouseLocationSn) {
  323. data.list[i].warehouseSnBackups = warehouseSn
  324. data.list[i].warehouseLocationSnBackups = warehouseLocationSn
  325. data.list[i].warehouseCascade = [warehouseSn, warehouseLocationSn]
  326. } else {
  327. data.list[i].warehouseCascade = undefined
  328. }
  329. // 成本小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  330. data.list[i].costSubtotal = getOperationalPrecision(data.list[i].putCost, data.list[i].putQty)
  331. }
  332. this.chooseLoadDataSource = data.list
  333. return data
  334. })
  335. },
  336. loadDataSource: [],
  337. chooseLoadDataSource: [],
  338. openModal: false, // 选择基本信息弹框是否显示
  339. warehouseList: [], // 仓库 下拉数据
  340. warehouseLocList: {}, // 仓位 下拉数据
  341. defaultWarehouseCascade: [], // 默认仓库仓位
  342. chooseWarehouseList: [], // 已选产品 仓库 下拉数据
  343. chooseWarehouseLocList: {}, // 已选产品 仓位 下拉数据
  344. basicInfoData: null, // 基本信息
  345. productTotal: null // 合计
  346. }
  347. },
  348. methods: {
  349. // 重置
  350. resetSearchForm () {
  351. this.queryParam.queryWord = ''
  352. this.queryParam.productBrandSn = undefined
  353. this.queryParam.productTypeSn1 = ''
  354. this.queryParam.productTypeSn2 = ''
  355. this.queryParam.productTypeSn3 = ''
  356. this.productType = []
  357. this.$refs.table.refresh(true)
  358. },
  359. // 打印预览/快捷打印
  360. handlePrint (type, printerType) {
  361. const _this = this
  362. _this.spinning = true
  363. const url = sparePartsPurDetailPrint
  364. const params = { sn: this.$route.params.sn, type: printerType }
  365. // 打印或导出
  366. hdPrint(printerType, type, url, params, '', function () {
  367. _this.spinning = false
  368. })
  369. },
  370. // 双击快速添加
  371. handleClickRow (record) {
  372. return {
  373. on: {
  374. dblclick: (event) => {
  375. this.handleAdd(record)
  376. }
  377. }
  378. }
  379. },
  380. // 基本信息
  381. getDetail () {
  382. sparePartsPurDetail({ id: this.$route.params.id }).then(res => {
  383. if (res.status == 200) {
  384. this.basicInfoData = res.data
  385. } else {
  386. this.basicInfoData = null
  387. }
  388. })
  389. },
  390. // 添加/编辑
  391. handleAdd (row, isEdit) {
  392. if (!isEdit && !(row.putCost || row.putCost == 0)) {
  393. this.$message.warning('请输入成本价后再添加!')
  394. return
  395. }
  396. if (!isEdit && !row.putQty) {
  397. this.$message.warning('请输入数量后再添加!')
  398. return
  399. }
  400. if (!isEdit && !row.warehouseSn) {
  401. this.$message.warning('请选择仓库后再添加!')
  402. return
  403. }
  404. if (!isEdit && !row.warehouseLocationSn) {
  405. this.$message.warning('请选择仓位后再添加!')
  406. return
  407. }
  408. const params = {
  409. id: isEdit ? row.id : undefined,
  410. sparePartsPurchaseSn: this.$route.params.sn,
  411. putCost: row.putCost,
  412. putQty: row.putQty,
  413. productCode: isEdit ? row.productCode : row.code,
  414. productOrigCode: (isEdit ? row.productOrigCode : row.origCode) || undefined,
  415. productSn: row.productSn,
  416. productTypeSn1: row.productTypeSn1,
  417. productTypeSn2: row.productTypeSn2,
  418. productTypeSn3: row.productTypeSn3,
  419. brandSn: isEdit ? row.brandSn : row.productBrandSn,
  420. warehouseLocationSn: row.warehouseLocationSn,
  421. warehouseSn: row.warehouseSn
  422. }
  423. if (isEdit) { // 编辑
  424. // 清空成本价或数量时,值应保持未清空前的值,因成本价和数量都不可为空
  425. if (!(row.putCost || row.putCost == 0)) {
  426. row.putCost = row.putCostBackups
  427. return
  428. }
  429. if (!row.putQty) {
  430. row.putQty = row.putQtyBackups
  431. return
  432. }
  433. }
  434. this.spinning = true
  435. sparePartsPurDetailSave(params).then(res => {
  436. if (res.status == 200) {
  437. this.$message.success(res.message)
  438. this.$refs.chooseTable.refresh()
  439. this.spinning = false
  440. } else {
  441. this.spinning = false
  442. }
  443. })
  444. },
  445. // 提交
  446. handleSubmit () {
  447. const _this = this
  448. _this.spinning = true
  449. sparePartsPurSubmit({ id: this.$route.params.id }).then(res => {
  450. if (res.status == 200) {
  451. this.$message.success(res.message)
  452. setTimeout(() => {
  453. _this.handleBack()
  454. _this.spinning = false
  455. }, 1000)
  456. } else {
  457. _this.spinning = false
  458. }
  459. })
  460. },
  461. // 删除
  462. handleDel (row) {
  463. const _this = this
  464. this.$confirm({
  465. title: '提示',
  466. content: '删除后不可恢复,确定要进行删除吗?',
  467. centered: true,
  468. onOk () {
  469. _this.spinning = true
  470. sparePartsPurDetailDel({ id: row.id }).then(res => {
  471. if (res.status == 200) {
  472. _this.$message.success(res.message)
  473. _this.$refs.chooseTable.refresh()
  474. _this.spinning = false
  475. } else {
  476. _this.spinning = false
  477. }
  478. })
  479. }
  480. })
  481. },
  482. // 编辑基本信息
  483. handleEditInfo () {
  484. this.openModal = true
  485. },
  486. // 基本信息 保存
  487. handleOk () {},
  488. // 导入明细
  489. handleImport () {
  490. console.log(333)
  491. },
  492. // 返回列表
  493. handleBack () {
  494. this.$router.push({ path: '/bulkManagement/bulkWarehousingOrder/list' })
  495. },
  496. // 合计
  497. getDetailCount (params) {
  498. sparePartsPurDetailCount(params).then(res => {
  499. if (res.status == 200) {
  500. this.productTotal = res.data
  501. } else {
  502. this.productTotal = null
  503. }
  504. })
  505. },
  506. changeWarehouseCascade (val, opt, ind, type) {
  507. let loadData
  508. if (type == 'dealerProduct') { // 全部产品
  509. loadData = this.loadDataSource[ind]
  510. } else if (type == 'sparePartsPurDetail') { // 已选产品
  511. loadData = this.chooseLoadDataSource[ind]
  512. }
  513. if (val.length < 2) {
  514. this.$message.warning('当前仓库无仓位,请选择其他仓库')
  515. const warehouseSnBackups = loadData.warehouseSnBackups || undefined
  516. const warehouseLocationSnBackups = loadData.warehouseLocationSnBackups || undefined
  517. loadData.warehouseSn = warehouseSnBackups
  518. loadData.warehouseLocationSn = warehouseLocationSnBackups
  519. if (warehouseSnBackups || warehouseLocationSnBackups) {
  520. loadData.warehouseCascade = [warehouseSnBackups, warehouseLocationSnBackups]
  521. } else {
  522. loadData.warehouseCascade = undefined
  523. }
  524. } else {
  525. loadData.warehouseSn = val[0] ? val[0] : ''
  526. loadData.warehouseLocationSn = val[1] ? val[1] : ''
  527. if (type == 'sparePartsPurDetail') { // 已选产品
  528. loadData = this.chooseLoadDataSource[ind]
  529. this.handleAdd(loadData, 'edit')
  530. }
  531. }
  532. },
  533. // 已选产品 成本价 blur
  534. putCostBlur (val, record) {
  535. // 光标移出,值发生改变再调用编辑接口
  536. if (val != record.putCostBackups || !val) {
  537. this.handleAdd(record, 'edit')
  538. }
  539. },
  540. // 已选产品 数量 blur
  541. putQtyBlur (val, record) {
  542. if (val != record.putQtyBackups) {
  543. this.handleAdd(record, 'edit')
  544. }
  545. },
  546. // 产品分类 change
  547. changeProductType (val, opt) {
  548. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  549. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  550. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  551. },
  552. // 仓库仓位 级联 列表
  553. getWarehouseCascade () {
  554. const _this = this
  555. warehouseCascadeList({}).then(res => {
  556. if (res.status == 200) {
  557. res.data.filter(item => {
  558. // 过滤默认仓库
  559. if (item.defaultFlag == 1 && item.wasteFlag == 0) { // defaultFlag为1,且不是废品仓
  560. _this.defaultWarehouseCascade[0] = item.warehouseSn
  561. // 过滤默认仓位
  562. item.warehouseLocationList.filter(subItem => {
  563. if (subItem.defaultFlag == 1 && subItem.wasteFlag == 0) {
  564. _this.defaultWarehouseCascade[1] = subItem.warehouseLocationSn
  565. _this.$refs.table.refresh(true)
  566. _this.$refs.chooseTable.refresh(true)
  567. }
  568. })
  569. }
  570. })
  571. res.data.map(item => {
  572. item.sn = item.warehouseSn
  573. if (item.warehouseLocationList) {
  574. item.warehouseLocationList.map(subItem => {
  575. subItem.sn = subItem.warehouseLocationSn
  576. })
  577. }
  578. })
  579. this.warehouseCascadeData = res.data
  580. } else {
  581. this.warehouseCascadeData = []
  582. }
  583. })
  584. },
  585. initPage () {
  586. this.getWarehouseCascade()
  587. this.getDetail()
  588. this.resetSearchForm()
  589. this.$refs.chooseTable.refresh(true)
  590. this.openModal = false
  591. }
  592. },
  593. mounted () {
  594. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  595. this.initPage()
  596. }
  597. },
  598. activated () {
  599. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  600. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  601. this.initPage()
  602. }
  603. },
  604. beforeRouteEnter (to, from, next) {
  605. next(vm => {})
  606. }
  607. }
  608. </script>
  609. <style lang="less">
  610. .bulkWarehousingOrderEdit-wrap{
  611. position: relative;
  612. height: 100%;
  613. padding-bottom: 51px;
  614. box-sizing: border-box;
  615. >.ant-spin-nested-loading{
  616. overflow-y: scroll;
  617. height: 100%;
  618. }
  619. .bulkWarehousingOrderEdit-cont{
  620. margin-bottom: 10px;
  621. .sub-title{
  622. font-size: 12px;
  623. color: #808695;
  624. margin-left: 10px;
  625. }
  626. }
  627. }
  628. </style>