edit.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  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="{ x: 1240, 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="1"
  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="{ x: 1320, 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="1"
  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 { STable, VSelect } from '@/components'
  219. import basicInfoModal from './basicInfoModal.vue'
  220. import { getOperationalPrecision } from '@/libs/tools.js'
  221. import { sparePartsPurDetail, sparePartsPurDetailList, sparePartsPurDetailCount, sparePartsPurDetailSave, sparePartsPurDetailDel, sparePartsPurSubmit, sparePartsPurDetailPrint } from '@/api/sparePartsPur'
  222. import { bulkProductList } from '@/api/dealerProduct'
  223. import { warehouseCascadeList } from '@/api/warehouse'
  224. import ProductType from '../../common/productType.js'
  225. import ProductBrand from '../../common/productBrand.js'
  226. import Print from '@/views/common/print.vue'
  227. import { hdPrint } from '@/libs/JGPrint'
  228. export default {
  229. components: { STable, VSelect, basicInfoModal, Print, ProductType, ProductBrand },
  230. data () {
  231. return {
  232. spinning: false,
  233. loading: false,
  234. chooseLoading: false,
  235. queryParam: {
  236. queryWord: '',
  237. productBrandSn: undefined,
  238. productTypeSn1: undefined,
  239. productTypeSn2: undefined,
  240. productTypeSn3: undefined
  241. },
  242. productType: [],
  243. warehouseCascadeData: [], // 仓库仓位
  244. disabled: false, // 查询、重置按钮是否可操作
  245. // 表头
  246. columns: [
  247. { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
  248. { title: '产品编码', dataIndex: 'code', width: 180, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  249. { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  250. { title: '原厂编码', dataIndex: 'origCode', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
  251. { title: '产品品牌', dataIndex: 'productBrandName', width: 140, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  252. { title: '单位', dataIndex: 'unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  253. { title: '成本价', scopedSlots: { customRender: 'putCost' }, width: 100, align: 'center' },
  254. { title: '数量', scopedSlots: { customRender: 'putQty' }, width: 100, align: 'center' },
  255. { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: 150, align: 'center' },
  256. { title: '操作', scopedSlots: { customRender: 'action' }, width: 80, align: 'center', fixed: 'right' }
  257. ],
  258. // 加载数据方法 必须为 Promise 对象
  259. loadData: parameter => {
  260. this.disabled = true
  261. parameter.sortAlias = 'dp'
  262. const params = Object.assign(parameter, this.queryParam, { supplierSn: this.$route.params.supplierSn })
  263. params.enabledFlag = 1
  264. return bulkProductList(params).then(res => {
  265. const data = res.data
  266. const no = (data.pageNo - 1) * data.pageSize
  267. for (var i = 0; i < data.list.length; i++) {
  268. data.list[i].no = no + i + 1
  269. data.list[i].putCost = data.list[i].purchasePrice || ''
  270. if (this.defaultWarehouseCascade.length > 0) {
  271. data.list[i].warehouseCascade = this.defaultWarehouseCascade
  272. data.list[i].warehouseSn = this.defaultWarehouseCascade[0]
  273. data.list[i].warehouseLocationSn = this.defaultWarehouseCascade[1]
  274. } else {
  275. data.list[i].warehouseCascade = undefined
  276. }
  277. }
  278. this.loadDataSource = data.list
  279. this.disabled = false
  280. return data
  281. })
  282. },
  283. // 表头
  284. chooseColumns: [
  285. { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
  286. { title: '产品编码', dataIndex: 'productCode', width: 180, align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
  287. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  288. { title: '原厂编码', dataIndex: 'productOrigCode', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
  289. { title: '产品品牌', dataIndex: 'brandName', width: 140, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  290. { title: '单位', dataIndex: 'productUnit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  291. { title: '成本价', scopedSlots: { customRender: 'putCost' }, width: 100, align: 'center' },
  292. { title: '数量', scopedSlots: { customRender: 'putQty' }, width: 100, align: 'center' },
  293. { title: '成本小计', dataIndex: 'costSubtotal', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  294. { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: 150, align: 'center' },
  295. { title: '操作', scopedSlots: { customRender: 'action' }, width: 80, align: 'center', fixed: 'right' }
  296. ],
  297. // 加载数据方法 必须为 Promise 对象
  298. chooseLoadData: parameter => {
  299. // 排序
  300. if (parameter.sortField == 'brandName') {
  301. parameter.sortField = 'productBrandName'
  302. parameter.sortAlias = 'dp'
  303. }
  304. if (parameter.sortField == 'productName') {
  305. parameter.sortField = 'productCode'
  306. parameter.sortAlias = 'sppd'
  307. }
  308. const params = Object.assign(parameter, { sparePartsPurchaseSn: this.$route.params.sn })
  309. return sparePartsPurDetailList(params).then(res => {
  310. this.getDetailCount(params)
  311. const data = res.data
  312. const no = (data.pageNo - 1) * data.pageSize
  313. for (var i = 0; i < data.list.length; i++) {
  314. data.list[i].no = no + i + 1
  315. data.list[i].putCostBackups = data.list[i].putCost
  316. data.list[i].putQtyBackups = data.list[i].putQty
  317. const warehouseSn = data.list[i].warehouseSn || undefined
  318. const warehouseLocationSn = data.list[i].warehouseLocationSn || undefined
  319. if (warehouseSn || warehouseLocationSn) {
  320. data.list[i].warehouseSnBackups = warehouseSn
  321. data.list[i].warehouseLocationSnBackups = warehouseLocationSn
  322. data.list[i].warehouseCascade = [warehouseSn, warehouseLocationSn]
  323. } else {
  324. data.list[i].warehouseCascade = undefined
  325. }
  326. // 成本小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  327. data.list[i].costSubtotal = getOperationalPrecision(data.list[i].putCost, data.list[i].putQty)
  328. }
  329. this.chooseLoadDataSource = data.list
  330. return data
  331. })
  332. },
  333. loadDataSource: [],
  334. chooseLoadDataSource: [],
  335. openModal: false, // 选择基本信息弹框是否显示
  336. warehouseList: [], // 仓库 下拉数据
  337. warehouseLocList: {}, // 仓位 下拉数据
  338. defaultWarehouseCascade: [], // 默认仓库仓位
  339. chooseWarehouseList: [], // 已选产品 仓库 下拉数据
  340. chooseWarehouseLocList: {}, // 已选产品 仓位 下拉数据
  341. basicInfoData: null, // 基本信息
  342. productTotal: null // 合计
  343. }
  344. },
  345. methods: {
  346. // 重置
  347. resetSearchForm () {
  348. this.queryParam.queryWord = ''
  349. this.queryParam.productBrandSn = undefined
  350. this.queryParam.productTypeSn1 = ''
  351. this.queryParam.productTypeSn2 = ''
  352. this.queryParam.productTypeSn3 = ''
  353. this.productType = []
  354. this.$refs.table.refresh(true)
  355. },
  356. // 打印预览/快捷打印
  357. handlePrint (type, printerType) {
  358. const _this = this
  359. _this.spinning = true
  360. const url = sparePartsPurDetailPrint
  361. const params = { sn: this.$route.params.sn, type: printerType }
  362. // 打印或导出
  363. hdPrint(printerType, type, url, params, '', function () {
  364. _this.spinning = false
  365. })
  366. },
  367. // 双击快速添加
  368. handleClickRow (record) {
  369. return {
  370. on: {
  371. dblclick: (event) => {
  372. this.handleAdd(record)
  373. }
  374. }
  375. }
  376. },
  377. // 基本信息
  378. getDetail () {
  379. sparePartsPurDetail({ id: this.$route.params.id }).then(res => {
  380. if (res.status == 200) {
  381. this.basicInfoData = res.data
  382. } else {
  383. this.basicInfoData = null
  384. }
  385. })
  386. },
  387. // 添加/编辑
  388. handleAdd (row, isEdit) {
  389. if (!isEdit && !row.putCost) {
  390. this.$message.warning('请输入成本价后再添加!')
  391. return
  392. }
  393. if (!isEdit && !row.putQty) {
  394. this.$message.warning('请输入数量后再添加!')
  395. return
  396. }
  397. if (!isEdit && !row.warehouseSn) {
  398. this.$message.warning('请选择仓库后再添加!')
  399. return
  400. }
  401. if (!isEdit && !row.warehouseLocationSn) {
  402. this.$message.warning('请选择仓位后再添加!')
  403. return
  404. }
  405. const params = {
  406. id: isEdit ? row.id : undefined,
  407. sparePartsPurchaseSn: this.$route.params.sn,
  408. putCost: row.putCost,
  409. putQty: row.putQty,
  410. productCode: isEdit ? row.productCode : row.code,
  411. productOrigCode: (isEdit ? row.productOrigCode : row.origCode) || undefined,
  412. productSn: row.productSn,
  413. productTypeSn1: row.productTypeSn1,
  414. productTypeSn2: row.productTypeSn2,
  415. productTypeSn3: row.productTypeSn3,
  416. brandSn: isEdit ? row.brandSn : row.productBrandSn,
  417. warehouseLocationSn: row.warehouseLocationSn,
  418. warehouseSn: row.warehouseSn
  419. }
  420. if (isEdit) { // 编辑
  421. // 清空成本价或数量时,值应保持未清空前的值,因成本价和数量都不可为空
  422. if (!row.putCost) {
  423. row.putCost = row.putCostBackups
  424. return
  425. }
  426. if (!row.putQty) {
  427. row.putQty = row.putQtyBackups
  428. return
  429. }
  430. }
  431. this.spinning = true
  432. sparePartsPurDetailSave(params).then(res => {
  433. if (res.status == 200) {
  434. this.$message.success(res.message)
  435. this.$refs.chooseTable.refresh()
  436. this.spinning = false
  437. } else {
  438. this.spinning = false
  439. }
  440. })
  441. },
  442. // 提交
  443. handleSubmit () {
  444. const _this = this
  445. _this.spinning = true
  446. sparePartsPurSubmit({ id: this.$route.params.id }).then(res => {
  447. if (res.status == 200) {
  448. this.$message.success(res.message)
  449. setTimeout(() => {
  450. _this.handleBack()
  451. _this.spinning = false
  452. }, 1000)
  453. } else {
  454. _this.spinning = false
  455. }
  456. })
  457. },
  458. // 删除
  459. handleDel (row) {
  460. const _this = this
  461. this.$confirm({
  462. title: '提示',
  463. content: '删除后不可恢复,确定要进行删除吗?',
  464. centered: true,
  465. onOk () {
  466. _this.spinning = true
  467. sparePartsPurDetailDel({ id: row.id }).then(res => {
  468. if (res.status == 200) {
  469. _this.$message.success(res.message)
  470. _this.$refs.chooseTable.refresh()
  471. _this.spinning = false
  472. } else {
  473. _this.spinning = false
  474. }
  475. })
  476. }
  477. })
  478. },
  479. // 编辑基本信息
  480. handleEditInfo () {
  481. this.openModal = true
  482. },
  483. // 基本信息 保存
  484. handleOk () {},
  485. // 导入明细
  486. handleImport () {
  487. console.log(333)
  488. },
  489. // 返回列表
  490. handleBack () {
  491. this.$router.push({ path: '/bulkManagement/bulkWarehousingOrder/list', query: { closeLastOldTab: true } })
  492. },
  493. // 合计
  494. getDetailCount (params) {
  495. sparePartsPurDetailCount(params).then(res => {
  496. if (res.status == 200) {
  497. this.productTotal = res.data
  498. } else {
  499. this.productTotal = null
  500. }
  501. })
  502. },
  503. changeWarehouseCascade (val, opt, ind, type) {
  504. let loadData
  505. if (type == 'dealerProduct') { // 全部产品
  506. loadData = this.loadDataSource[ind]
  507. } else if (type == 'sparePartsPurDetail') { // 已选产品
  508. loadData = this.chooseLoadDataSource[ind]
  509. }
  510. if (val.length < 2) {
  511. this.$message.warning('当前仓库无仓位,请选择其他仓库')
  512. const warehouseSnBackups = loadData.warehouseSnBackups || undefined
  513. const warehouseLocationSnBackups = loadData.warehouseLocationSnBackups || undefined
  514. loadData.warehouseSn = warehouseSnBackups
  515. loadData.warehouseLocationSn = warehouseLocationSnBackups
  516. if (warehouseSnBackups || warehouseLocationSnBackups) {
  517. loadData.warehouseCascade = [warehouseSnBackups, warehouseLocationSnBackups]
  518. } else {
  519. loadData.warehouseCascade = undefined
  520. }
  521. } else {
  522. loadData.warehouseSn = val[0] ? val[0] : ''
  523. loadData.warehouseLocationSn = val[1] ? val[1] : ''
  524. if (type == 'sparePartsPurDetail') { // 已选产品
  525. loadData = this.chooseLoadDataSource[ind]
  526. this.handleAdd(loadData, 'edit')
  527. }
  528. }
  529. },
  530. // 已选产品 成本价 blur
  531. putCostBlur (val, record) {
  532. // 光标移出,值发生改变再调用编辑接口
  533. if (val != record.putCostBackups) {
  534. this.handleAdd(record, 'edit')
  535. }
  536. },
  537. // 已选产品 数量 blur
  538. putQtyBlur (val, record) {
  539. if (val != record.putQtyBackups) {
  540. this.handleAdd(record, 'edit')
  541. }
  542. },
  543. // 产品分类 change
  544. changeProductType (val, opt) {
  545. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  546. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  547. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  548. },
  549. // 仓库仓位 级联 列表
  550. getWarehouseCascade () {
  551. const _this = this
  552. warehouseCascadeList({}).then(res => {
  553. if (res.status == 200) {
  554. res.data.filter(item => {
  555. // 过滤默认仓库
  556. if (item.defaultFlag == 1 && item.wasteFlag == 0) { // defaultFlag为1,且不是废品仓
  557. _this.defaultWarehouseCascade[0] = item.warehouseSn
  558. // 过滤默认仓位
  559. item.warehouseLocationList.filter(subItem => {
  560. if (subItem.defaultFlag == 1 && subItem.wasteFlag == 0) {
  561. _this.defaultWarehouseCascade[1] = subItem.warehouseLocationSn
  562. _this.$refs.table.refresh(true)
  563. _this.$refs.chooseTable.refresh(true)
  564. }
  565. })
  566. }
  567. })
  568. res.data.map(item => {
  569. item.sn = item.warehouseSn
  570. if (item.warehouseLocationList) {
  571. item.warehouseLocationList.map(subItem => {
  572. subItem.sn = subItem.warehouseLocationSn
  573. })
  574. }
  575. })
  576. this.warehouseCascadeData = res.data
  577. } else {
  578. this.warehouseCascadeData = []
  579. }
  580. })
  581. },
  582. initPage () {
  583. this.getWarehouseCascade()
  584. this.getDetail()
  585. this.resetSearchForm()
  586. this.$refs.chooseTable.refresh(true)
  587. this.openModal = false
  588. }
  589. },
  590. mounted () {
  591. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  592. this.initPage()
  593. }
  594. },
  595. activated () {
  596. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  597. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  598. this.initPage()
  599. }
  600. },
  601. beforeRouteEnter (to, from, next) {
  602. next(vm => {})
  603. }
  604. }
  605. </script>
  606. <style lang="less">
  607. .bulkWarehousingOrderEdit-wrap{
  608. position: relative;
  609. height: 100%;
  610. padding-bottom: 51px;
  611. box-sizing: border-box;
  612. >.ant-spin-nested-loading{
  613. overflow-y: scroll;
  614. height: 100%;
  615. }
  616. .bulkWarehousingOrderEdit-cont{
  617. margin-bottom: 10px;
  618. .sub-title{
  619. font-size: 12px;
  620. color: #808695;
  621. margin-left: 10px;
  622. }
  623. }
  624. }
  625. </style>