edit.vue 34 KB

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