edit.vue 29 KB

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