edit.vue 34 KB

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