edit.vue 28 KB

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