set.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. <template>
  2. <div class="shelfSet-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" @back="handleBack" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="shelfSet-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. </template>
  9. </a-page-header>
  10. <!-- 内容 -->
  11. <a-card size="small" :bordered="false" class="shelfSet-cont">
  12. <a-collapse :activeKey="['1']">
  13. <a-collapse-panel key="1">
  14. <template slot="header">
  15. <span>基础信息</span>
  16. <a-button
  17. icon="edit"
  18. v-if="basicInfoData&&basicInfoData.state!='WRITE_OFF'&&basicInfoData.state!='SUSPEND'"
  19. size="small"
  20. type="link"
  21. style="margin-left: 20px;color: #39f;"
  22. @click.stop="openInfoModal = true">编辑</a-button>
  23. </template>
  24. <a-descriptions :column="2">
  25. <a-descriptions-item label="货架名称">
  26. {{ basicInfoData&&basicInfoData.shelfName || '--' }}
  27. <a-badge count="已注销" :number-style="{ zoom:'80%',marginLeft:'5px', color: '#fff',background:'#999' }" v-if="basicInfoData&&basicInfoData.state=='WRITE_OFF'"></a-badge>
  28. <a-badge count="已停用" :number-style="{ zoom:'80%',marginLeft:'5px', color: '#fff',background:'#999' }" v-if="basicInfoData&&basicInfoData.state=='DISABLED'"></a-badge>
  29. <a-badge count="已暂停" :number-style="{ zoom:'80%',marginLeft:'5px', color: '#fff',background:'#999' }" v-if="basicInfoData&&basicInfoData.state=='SUSPEND'"></a-badge>
  30. </a-descriptions-item>
  31. <a-descriptions-item>
  32. <template slot="label">
  33. 货架产品
  34. </template>
  35. <span>{{ showPriceStr.length ? showPriceStr.join("/") : '--' }}</span>
  36. </a-descriptions-item>
  37. <a-descriptions-item>
  38. <template slot="label">
  39. <a-tooltip placement="top">
  40. <template slot="title">
  41. <span>此数字货架,归属于您的哪一位客户。如果没有搜索到客户,请在客户管理功能中新建客户。</span>
  42. </template>
  43. 关联客户<a-icon type="question-circle" style="color: rgba(0,0,0,.65);font-size: 16px;margin-left: 2px;vertical-align: sub;cursor: pointer;" />
  44. </a-tooltip>
  45. </template>
  46. {{ (basicInfoData&&basicInfoData.customerEntity&&basicInfoData.customerEntity.customerName) || '--' }}
  47. </a-descriptions-item>
  48. <a-descriptions-item>
  49. <template slot="label">
  50. 非货架产品
  51. </template>
  52. <span>{{ showNoShelfPriceStr.length ? showNoShelfPriceStr.join("/") : '--' }}</span>
  53. </a-descriptions-item>
  54. </a-descriptions>
  55. </a-collapse-panel>
  56. </a-collapse>
  57. </a-card>
  58. <a-card size="small" :bordered="false" class="shelfSet-cont">
  59. <!-- 搜索条件 -->
  60. <div ref="tableSearch" class="table-page-search-wrapper">
  61. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  62. <a-row :gutter="15">
  63. <a-col :md="6" :sm="24">
  64. <a-form-item label="产品编码">
  65. <a-input id="shelfSet-productCode" v-model.trim="queryParam.shelfProductApiEntity.productCode" allowClear placeholder="请输入产品编码"/>
  66. </a-form-item>
  67. </a-col>
  68. <a-col :md="6" :sm="24">
  69. <a-form-item label="产品名称">
  70. <a-input id="shelfSet-productName" v-model.trim="queryParam.shelfProductApiEntity.productName" allowClear placeholder="请输入产品名称"/>
  71. </a-form-item>
  72. </a-col>
  73. <a-col :md="6" :sm="24">
  74. <span class="table-page-search-submitButtons">
  75. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="shelfSet-refresh">查询</a-button>
  76. <a-button style="margin-left: 5px" @click="resetSearchForm()" :disabled="disabled" id="shelfSet-reset">重置</a-button>
  77. <a-button
  78. type="primary"
  79. class="button-warning"
  80. @click="handleExport"
  81. :disabled="disabled"
  82. :loading="exportLoading"
  83. >导出</a-button>
  84. </span>
  85. </a-col>
  86. </a-row>
  87. </a-form>
  88. </div>
  89. <!-- 操作按钮 -->
  90. <div class="table-operator" v-if="basicInfoData&&basicInfoData.state!='WRITE_OFF'&&basicInfoData.state!='SUSPEND'">
  91. <a-button id="shelfSet-addHW" type="primary" class="button-error" @click="addHW(1)">新增货位</a-button>
  92. <a-button id="shelfSet-imports" type="primary" class="button-info" @click="addHW(0)">批量导入货位</a-button>
  93. <a-button id="shelfSet-importProduct" type="primary" class="button-error" @click="openGuideModal=true">导入绑定产品</a-button>
  94. <a-tooltip placement="top">
  95. <template slot="title">
  96. <span>如果货位还没有绑定产品,可使用此功能通过Excel批量导入</span>
  97. </template>
  98. <a-icon type="question-circle" style="color: rgba(0,0,0,.45);font-size: 16px;margin-left: 5px;vertical-align: middle;cursor: pointer;" />
  99. </a-tooltip>
  100. <a-button
  101. v-if="showTplBtn"
  102. id="shelfSet-import-template"
  103. style="margin-left:10px;"
  104. type="primary"
  105. class="button-primary"
  106. @click="showTplModal=true">导入模板</a-button>
  107. </div>
  108. <!-- 列表 -->
  109. <s-table
  110. class="sTable"
  111. ref="table"
  112. size="small"
  113. :scroll="{ y: tableHeight }"
  114. :rowKey="(record) => record.id"
  115. :columns="columns"
  116. :data="loadData"
  117. :showPagination="false"
  118. :defaultLoadData="false"
  119. bordered>
  120. <span slot="customTitle">
  121. 结算价
  122. <a-popover>
  123. <template slot="content">
  124. 即易码通进货价
  125. </template>
  126. <a-icon type="question-circle"/>
  127. </a-popover>
  128. </span>
  129. <!-- 操作 -->
  130. <template slot="action" slot-scope="text, record">
  131. <a-button
  132. :id="'shelfSet-link-'+record.id"
  133. size="small"
  134. type="link"
  135. :class="record.enableFlag==1?'button-error':'button-primary'"
  136. v-if="record.shelfProductApiEntity&&(!record.shelfProductApiEntity.qty||(record.enableFlag==0&&record.shelfProductApiEntity.qty))&&record.shelfProductApiEntity.productSn"
  137. @click="handleEnable(record)"
  138. >{{ record.enableFlag==1?'禁用':'启用' }}</a-button>
  139. <a-button
  140. :id="'shelfSet-bindProduct-'+record.id"
  141. size="small"
  142. type="link"
  143. class="button-primary"
  144. v-if="!(record.shelfProductApiEntity&&record.shelfProductApiEntity.productSn)"
  145. @click="handleProduct(record, 'bind')"
  146. >绑定产品</a-button>
  147. <a-button
  148. :id="'shelfSet-editProduct-'+record.id"
  149. size="small"
  150. type="link"
  151. :class="record.enableFlag==1?'button-primary':''"
  152. :disabled="record.enableFlag==0"
  153. v-else
  154. @click="handleReplace(record)"
  155. >更换产品</a-button>
  156. <a-button
  157. :id="'shelfSet-editHw-'+record.id"
  158. size="small"
  159. type="link"
  160. :class="record.enableFlag==1?'button-primary':''"
  161. :disabled="record.enableFlag==0"
  162. @click="editHW(record)"
  163. >编辑</a-button>
  164. <a-button
  165. :id="'shelfSet-del-'+record.id"
  166. size="small"
  167. type="link"
  168. class="button-error"
  169. v-if="!(record.shelfProductApiEntity&&record.shelfProductApiEntity.productSn)"
  170. @click="handleDel(record)"
  171. >删除</a-button>
  172. </template>
  173. </s-table>
  174. </a-card>
  175. </a-spin>
  176. <!-- 基础设置 -->
  177. <basic-info-modal :openModal="openInfoModal" :nowData="basicInfoData" @ok="handleInfoOk" @close="openInfoModal=false" />
  178. <!-- 修改信息/绑定产品/更换产品 -->
  179. <bind-product-modal :openModal="openModal" :type="modalType" :nowData="nowData" @ok="$refs.table.refresh()" @close="handleCancel" />
  180. <!-- 编辑、新增货位 -->
  181. <addHwModal :openModal="openHwModal" :type="modalType" :nowData="nowData" @ok="$refs.table.refresh()" @close="handleCancel" />
  182. <!-- 更换产品 -->
  183. <common-modal
  184. :openModal="openTipsModal"
  185. modalHtml="只有当前库存为0时,才能更换产品<br/>您可以在“货架监控”功能中将产品调回"
  186. okText="好的"
  187. :isCancel="false"
  188. @ok="openTipsModal=false"
  189. @close="openTipsModal=false" />
  190. <!-- 导入产品 -->
  191. <importGuideModal :openModal="openGuideModal" :params="{shelfSn: $route.params.sn}" @close="openGuideModal=false" @ok="handleGuideOk" />
  192. <!-- 导入货位弹框 -->
  193. <importHuoweiModal :openModal="openImportModal" @close="openImportModal=false" @ok="$refs.table.refresh(true)" :shelfSn="$route.params.sn"></importHuoweiModal>
  194. <!-- 导入货架模板弹框 -->
  195. <commonModal modalTit="导入货架模板" :openModal="showTplModal" @close="closeTplModal" @ok="saveTpl">
  196. <shelfTemplate v-if="showTplModal" style="width:100%" v-model="tplSn"></shelfTemplate>
  197. </commonModal>
  198. </div>
  199. </template>
  200. <script>
  201. import { commonMixin } from '@/utils/mixin'
  202. import { downloadExcel } from '@/libs/JGPrint.js'
  203. import { STable, VSelect } from '@/components'
  204. import commonModal from '@/views/common/commonModal.vue' // 公共提示弹框
  205. import addHwModal from './addHwModal.vue' // 新增货位弹框
  206. import bindProductModal from './bindProductModal.vue' // 绑定产品弹框
  207. import ImportGuideModal from './importGuideModal.vue' // 导入产品弹框
  208. import basicInfoModal from './basicInfoModal.vue' // 基本信息弹框
  209. import importHuoweiModal from './importHuoweiModal.vue' // 导入货位模板
  210. import shelfTemplate from '@/views/common/shelfTemplate' // 货架模板下拉组件
  211. import { shelfDetail, shelfProductList, shelfProductBatchInsert, delShelfPlaceSn, shelfProductEnable, getShelfPriceShow, shelfProductExport, importShelfTemplate } from '@/api/shelf'
  212. export default {
  213. name: 'ShelfMonitoringWarehousing',
  214. components: { STable, VSelect, commonModal, bindProductModal, addHwModal, ImportGuideModal, basicInfoModal, importHuoweiModal, shelfTemplate },
  215. mixins: [commonMixin],
  216. data () {
  217. return {
  218. spinning: false, // 页面loading
  219. disabled: false, // 查询、重置按钮是否可操作
  220. tableHeight: 400, // 表格高度
  221. exportLoading: false, // 导出loading
  222. showTplModal: false, // 是否显示导入模板弹框
  223. tplSn: undefined, // 货架模板sn
  224. queryParam: {
  225. shelfProductApiEntity: {
  226. productCode: '', // 产品编码
  227. productName: '' // 产品名称
  228. }
  229. },
  230. orginData: [], // 原始数据
  231. // 加载数据方法 必须为 Promise 对象
  232. loadData: parameter => {
  233. this.disabled = true
  234. this.spinning = true
  235. return shelfProductList(Object.assign(parameter, this.queryParam, { shelfSn: this.$route.params.sn })).then(res => {
  236. let data
  237. if (res.status == 200) {
  238. data = res.data
  239. for (var i = 0; i < data.length; i++) {
  240. data[i].no = i + 1
  241. data[i].enableFlag = data[i].shelfProductApiEntity && data[i].shelfProductApiEntity.enableFlag
  242. }
  243. this.disabled = false
  244. this.orginData = data
  245. }
  246. this.spinning = false
  247. return data
  248. })
  249. },
  250. basicInfoData: null, // 基础设置弹框
  251. openTipsModal: false, // 更换产品提示弹框
  252. openModal: false, // 修改信息/绑定产品/更换产品弹框
  253. nowData: null, // 当前操作货位产品数据
  254. openGuideModal: false, // 导入产品
  255. modalType: null, // 新增或编辑
  256. openInfoModal: false, // 基础设置弹框
  257. openHwModal: false, // 新增编辑货位弹框
  258. openImportModal: false, // 导入货位模板弹框
  259. showPriceStr: [], // 货架产品价格权限
  260. showNoShelfPriceStr: [] // 非货架产品价格权限
  261. }
  262. },
  263. computed: {
  264. // 是否显示模板导入按钮
  265. showTplBtn () {
  266. return this.orginData.length == 0
  267. },
  268. // 列定义
  269. columns () {
  270. const _this = this
  271. const ret = [
  272. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  273. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  274. { title: '绑定产品编码', dataIndex: 'shelfProductApiEntity.productCode', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  275. { title: '绑定产品名称', dataIndex: 'shelfProductApiEntity.productName', width: '23%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  276. { title: '车主价', dataIndex: 'shelfProductApiEntity.price', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  277. { slots: { title: 'customTitle' }, dataIndex: 'shelfProductApiEntity.cost', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  278. { title: '最大库容', dataIndex: 'shelfProductApiEntity.maxQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  279. { title: '当前库存', dataIndex: 'shelfProductApiEntity.qty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  280. ]
  281. // 注销或停用的货架不能操作
  282. if (this.basicInfoData && this.basicInfoData.state != 'WRITE_OFF' && this.basicInfoData.state != 'SUSPEND') {
  283. ret.push({ title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' })
  284. }
  285. return ret
  286. }
  287. },
  288. methods: {
  289. // 获取价格显示设置
  290. getShelfPriceShow () {
  291. this.showPriceStr = []
  292. this.showNoShelfPriceStr = []
  293. getShelfPriceShow({ shelfSn: this.$route.params.sn }).then(res => {
  294. if (res.status == 200) {
  295. const ret = res.data && res.data
  296. this.basicInfoData.showPrice = ret
  297. ret.map(item => {
  298. if (item.paramCode == 'shelf_price_show' && item.paramValue == 1) {
  299. this.showPriceStr.push('车主价')
  300. }
  301. if (item.paramCode == 'shelf_cost_show' && item.paramValue == 1) {
  302. this.showPriceStr.push('结算价')
  303. }
  304. if (item.paramCode == 'non_shelf_price_show' && item.paramValue == 1) {
  305. this.showNoShelfPriceStr.push('车主价')
  306. }
  307. if (item.paramCode == 'non_shelf_cost_show' && item.paramValue == 1) {
  308. this.showNoShelfPriceStr.push('结算价')
  309. }
  310. })
  311. }
  312. })
  313. },
  314. closeTplModal () {
  315. this.tplSn = undefined
  316. this.showTplModal = false
  317. },
  318. // 导入模板成功
  319. saveTpl () {
  320. if (!this.tplSn) {
  321. this.$message.success('请选择货架模板')
  322. return
  323. }
  324. if (!this.spinning) {
  325. this.spinning = true
  326. importShelfTemplate({ shelfSn: this.$route.params.sn, templateSn: this.tplSn }).then(res => {
  327. if (res.status == 200) {
  328. this.$message.success(res.message)
  329. this.showTplModal = false
  330. this.resetSearchForm()
  331. }
  332. this.spinning = false
  333. })
  334. }
  335. },
  336. // 导出产品
  337. handleExport () {
  338. this.exportLoading = true
  339. shelfProductExport({ shelfSn: this.$route.params.sn }).then(res => {
  340. downloadExcel(res, (this.basicInfoData ? this.basicInfoData.shelfName : '') + '的产品')
  341. this.exportLoading = false
  342. })
  343. },
  344. // 导入或新增货位
  345. addHW (type) {
  346. // 导入货位
  347. if (type == 0) {
  348. this.openImportModal = true
  349. } else {
  350. // 新增货位
  351. this.nowData = this.basicInfoData
  352. this.modalType = 'add'
  353. this.openHwModal = true
  354. }
  355. },
  356. // 禁用启用弹框提示
  357. handleEnable (row) {
  358. const _this = this
  359. if (row.enableFlag == 1) {
  360. this.$confirm({
  361. title: '提示',
  362. content: '禁用后不参于盘点和补货,但是可以退货、调回,确认禁用吗?',
  363. centered: true,
  364. onOk () {
  365. _this.enableFun(row)
  366. }
  367. })
  368. } else {
  369. _this.enableFun(row)
  370. }
  371. },
  372. // 禁用启用货架
  373. enableFun (row) {
  374. const _this = this
  375. _this.spinning = true
  376. shelfProductEnable({
  377. shelfSn: this.$route.params.sn,
  378. shelfProductSn: row.shelfProductApiEntity.shelfProductSn,
  379. enableFlag: row.enableFlag == 1 ? 0 : 1
  380. }).then(res => {
  381. if (res.status == 200) {
  382. _this.$message.success(res.message)
  383. _this.$refs.table.refresh()
  384. }
  385. _this.spinning = false
  386. })
  387. },
  388. // 编辑货位
  389. editHW (row) {
  390. // 已绑定产品,不能编辑货位号,只能编辑已绑定产品的销售价、结算价、最大库容
  391. if (row.shelfProductApiEntity && row.shelfProductApiEntity.productSn) {
  392. this.handleProduct(row, 'edit')
  393. } else {
  394. // 货位没有绑定产品,仅编辑货位号
  395. this.nowData = Object.assign(this.basicInfoData, row)
  396. this.modalType = 'edit'
  397. this.openHwModal = true
  398. }
  399. },
  400. // 基本信息
  401. getDetail () {
  402. shelfDetail({ sn: this.$route.params.sn }).then(res => {
  403. if (res.status == 200) {
  404. this.basicInfoData = res.data
  405. // 获取价格权限
  406. this.getShelfPriceShow()
  407. } else {
  408. this.basicInfoData = null
  409. }
  410. })
  411. },
  412. // 删除货位
  413. handleDel (row) {
  414. const _this = this
  415. this.$confirm({
  416. title: '提示',
  417. content: '删除后无法恢复,确认删除?',
  418. centered: true,
  419. onOk () {
  420. _this.spinning = true
  421. delShelfPlaceSn({ shelfPlaceSn: row.shelfPlaceSn }).then(res => {
  422. if (res.status == 200) {
  423. _this.$message.success(res.message)
  424. _this.$refs.table.refresh()
  425. }
  426. _this.spinning = false
  427. })
  428. }
  429. })
  430. },
  431. // 更换产品
  432. handleReplace (row) {
  433. if (row.shelfProductApiEntity.qty) {
  434. this.openTipsModal = true
  435. } else {
  436. this.handleProduct(row, 'replace')
  437. }
  438. },
  439. // 更换产品/绑定产品/修改信息
  440. handleProduct (row, type) {
  441. if (row) {
  442. this.nowData = Object.assign(row, { customerSn: this.basicInfoData && this.basicInfoData.customerEntity && this.basicInfoData.customerEntity.customerSn })
  443. } else {
  444. this.nowData = null
  445. }
  446. this.modalType = type
  447. this.openModal = true
  448. },
  449. // 编辑弹框取消
  450. handleCancel () {
  451. this.modalType = null
  452. this.nowData = null
  453. this.openModal = false
  454. this.openHwModal = false
  455. },
  456. // 导入成功
  457. handleGuideOk (obj) {
  458. shelfProductBatchInsert(obj).then(res => {
  459. if (res.status == 200) {
  460. this.$refs.table.refresh(true)
  461. }
  462. })
  463. },
  464. // 编辑基本信息成功
  465. handleInfoOk () {
  466. this.getDetail()
  467. },
  468. // 重置
  469. resetSearchForm () {
  470. this.queryParam.shelfProductApiEntity.productCode = ''
  471. this.queryParam.shelfProductApiEntity.productName = ''
  472. this.$refs.table.refresh(true)
  473. },
  474. // 计算表格高度
  475. setTableH () {
  476. const tableSearchH = this.$refs.tableSearch.offsetHeight
  477. this.tableHeight = window.innerHeight - tableSearchH - 350
  478. },
  479. // 返回列表
  480. handleBack () {
  481. this.$router.push({ path: '/numsGoodsShelves/shelfSet/list' })
  482. }
  483. },
  484. mounted () {
  485. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  486. this.setTableH()
  487. this.getDetail()
  488. this.resetSearchForm()
  489. }
  490. },
  491. activated () {
  492. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  493. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  494. this.setTableH()
  495. this.getDetail()
  496. this.resetSearchForm()
  497. }
  498. }
  499. }
  500. </script>
  501. <style lang="less">
  502. .shelfSet-wrap{
  503. .store-info{
  504. margin: 0 15px;
  505. color: rgb(102, 102, 102);
  506. }
  507. .shelfSet-cont{
  508. margin-top: 10px;
  509. }
  510. }
  511. </style>