edit.vue 30 KB

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