set.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  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. size="small"
  133. type="link"
  134. :class="record.enableFlag==1?'button-error':'button-primary'"
  135. v-if="record.shelfProductApiEntity&&(!record.shelfProductApiEntity.qty||(record.enableFlag==0&&record.shelfProductApiEntity.qty))&&record.shelfProductApiEntity.productSn"
  136. @click="handleEnable(record)"
  137. >{{ record.enableFlag==1?'禁用':'启用' }}</a-button>
  138. <a-button
  139. size="small"
  140. type="link"
  141. class="button-primary"
  142. v-if="!(record.shelfProductApiEntity&&record.shelfProductApiEntity.productSn)"
  143. @click="handleProduct(record, 'bind')"
  144. >绑定产品</a-button>
  145. <a-button
  146. size="small"
  147. type="link"
  148. :class="record.enableFlag==1?'button-primary':''"
  149. :disabled="record.enableFlag==0"
  150. v-else
  151. @click="handleReplace(record)"
  152. >更换产品</a-button>
  153. <a-button
  154. size="small"
  155. type="link"
  156. :class="record.enableFlag==1?'button-primary':''"
  157. :disabled="record.enableFlag==0"
  158. @click="editHW(record)"
  159. >编辑</a-button>
  160. <a-button
  161. size="small"
  162. type="link"
  163. class="button-error"
  164. v-if="!(record.shelfProductApiEntity&&record.shelfProductApiEntity.productSn)"
  165. @click="handleDel(record)"
  166. >删除</a-button>
  167. </template>
  168. </s-table>
  169. </a-card>
  170. </a-spin>
  171. <!-- 基础设置 -->
  172. <basic-info-modal :openModal="openInfoModal" :nowData="basicInfoData" @ok="handleInfoOk" @close="openInfoModal=false" />
  173. <!-- 修改信息/绑定产品/更换产品 -->
  174. <bind-product-modal :openModal="openModal" :type="modalType" :nowData="nowData" @ok="$refs.table.refresh()" @close="handleCancel" />
  175. <!-- 编辑、新增货位 -->
  176. <addHwModal :openModal="openHwModal" :type="modalType" :nowData="nowData" @ok="$refs.table.refresh()" @close="handleCancel" />
  177. <!-- 更换产品 -->
  178. <common-modal
  179. :openModal="openTipsModal"
  180. modalHtml="只有当前库存为0时,才能更换产品<br/>您可以在“货架监控”功能中将产品调回"
  181. okText="好的"
  182. :isCancel="false"
  183. @ok="openTipsModal=false"
  184. @close="openTipsModal=false" />
  185. <!-- 导入产品 -->
  186. <importGuideModal :openModal="openGuideModal" :params="{shelfSn: $route.params.sn}" @close="openGuideModal=false" @ok="handleGuideOk" />
  187. <!-- 导入货位弹框 -->
  188. <importHuoweiModal :openModal="openImportModal" @close="openImportModal=false" @ok="$refs.table.refresh(true)" :shelfSn="$route.params.sn"></importHuoweiModal>
  189. <!-- 导入货架模板弹框 -->
  190. <commonModal modalTit="导入货架模板" :openModal="showTplModal" @close="showTplModal=false" @ok="saveTpl">
  191. <shelfTemplate style="width:100%" v-model="tplSn"></shelfTemplate>
  192. </commonModal>
  193. </div>
  194. </template>
  195. <script>
  196. import { commonMixin } from '@/utils/mixin'
  197. import { downloadExcel } from '@/libs/JGPrint.js'
  198. import { STable, VSelect } from '@/components'
  199. import commonModal from '@/views/common/commonModal.vue' // 公共提示弹框
  200. import addHwModal from './addHwModal.vue' // 新增货位弹框
  201. import bindProductModal from './bindProductModal.vue' // 绑定产品弹框
  202. import ImportGuideModal from './importGuideModal.vue' // 导入产品弹框
  203. import basicInfoModal from './basicInfoModal.vue' // 基本信息弹框
  204. import importHuoweiModal from './importHuoweiModal.vue' // 导入货位模板
  205. import shelfTemplate from '@/views/common/shelfTemplate' // 货架模板下拉组件
  206. import { shelfDetail, shelfProductList, shelfProductBatchInsert, delShelfPlaceSn, shelfProductEnable, getShelfPriceShow, shelfProductExport, importShelfTemplate } from '@/api/shelf'
  207. export default {
  208. name: 'ShelfMonitoringWarehousing',
  209. components: { STable, VSelect, commonModal, bindProductModal, addHwModal, ImportGuideModal, basicInfoModal, importHuoweiModal, shelfTemplate },
  210. mixins: [commonMixin],
  211. data () {
  212. return {
  213. spinning: false, // 页面loading
  214. disabled: false, // 查询、重置按钮是否可操作
  215. tableHeight: 400, // 表格高度
  216. exportLoading: false, // 导出loading
  217. showTplModal: false, // 是否显示导入模板弹框
  218. tplSn: undefined, // 货架模板sn
  219. queryParam: {
  220. shelfProductApiEntity: {
  221. productCode: '', // 产品编码
  222. productName: '' // 产品名称
  223. }
  224. },
  225. orginData: [], // 原始数据
  226. // 加载数据方法 必须为 Promise 对象
  227. loadData: parameter => {
  228. this.disabled = true
  229. this.spinning = true
  230. return shelfProductList(Object.assign(parameter, this.queryParam, { shelfSn: this.$route.params.sn })).then(res => {
  231. let data
  232. if (res.status == 200) {
  233. data = res.data
  234. for (var i = 0; i < data.length; i++) {
  235. data[i].no = i + 1
  236. data[i].enableFlag = data[i].shelfProductApiEntity && data[i].shelfProductApiEntity.enableFlag
  237. }
  238. this.disabled = false
  239. this.orginData = data
  240. }
  241. this.spinning = false
  242. return data
  243. })
  244. },
  245. basicInfoData: null, // 基础设置弹框
  246. openTipsModal: false, // 更换产品提示弹框
  247. openModal: false, // 修改信息/绑定产品/更换产品弹框
  248. nowData: null, // 当前操作货位产品数据
  249. openGuideModal: false, // 导入产品
  250. modalType: null, // 新增或编辑
  251. openInfoModal: false, // 基础设置弹框
  252. openHwModal: false, // 新增编辑货位弹框
  253. openImportModal: false, // 导入货位模板弹框
  254. showPriceStr: [], // 货架产品价格权限
  255. showNoShelfPriceStr: [] // 非货架产品价格权限
  256. }
  257. },
  258. computed: {
  259. // 是否显示模板导入按钮
  260. showTplBtn () {
  261. return this.orginData.length == 0
  262. },
  263. // 列定义
  264. columns () {
  265. const _this = this
  266. const ret = [
  267. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  268. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  269. { title: '绑定产品编码', dataIndex: 'shelfProductApiEntity.productCode', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  270. { title: '绑定产品名称', dataIndex: 'shelfProductApiEntity.productName', width: '23%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  271. { title: '车主价', dataIndex: 'shelfProductApiEntity.price', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  272. { slots: { title: 'customTitle' }, dataIndex: 'shelfProductApiEntity.cost', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  273. { title: '最大库容', dataIndex: 'shelfProductApiEntity.maxQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  274. { title: '当前库存', dataIndex: 'shelfProductApiEntity.qty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  275. ]
  276. // 注销或停用的货架不能操作
  277. if (this.basicInfoData && this.basicInfoData.state != 'WRITE_OFF' && this.basicInfoData.state != 'SUSPEND') {
  278. ret.push({ title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' })
  279. }
  280. return ret
  281. }
  282. },
  283. methods: {
  284. // 获取价格显示设置
  285. getShelfPriceShow () {
  286. this.showPriceStr = []
  287. this.showNoShelfPriceStr = []
  288. getShelfPriceShow({ shelfSn: this.$route.params.sn }).then(res => {
  289. if (res.status == 200) {
  290. const ret = res.data && res.data
  291. this.basicInfoData.showPrice = ret
  292. ret.map(item => {
  293. if (item.paramCode == 'shelf_price_show' && item.paramValue == 1) {
  294. this.showPriceStr.push('车主价')
  295. }
  296. if (item.paramCode == 'shelf_cost_show' && item.paramValue == 1) {
  297. this.showPriceStr.push('结算价')
  298. }
  299. if (item.paramCode == 'non_shelf_price_show' && item.paramValue == 1) {
  300. this.showNoShelfPriceStr.push('车主价')
  301. }
  302. if (item.paramCode == 'non_shelf_cost_show' && item.paramValue == 1) {
  303. this.showNoShelfPriceStr.push('结算价')
  304. }
  305. })
  306. }
  307. })
  308. },
  309. // 导入模板成功
  310. saveTpl () {
  311. if (!this.tplSn) {
  312. this.$message.success('请选择货架模板')
  313. return
  314. }
  315. if (!this.spinning) {
  316. this.spinning = true
  317. importShelfTemplate({ shelfSn: this.$route.params.sn, templateSn: this.tplSn }).then(res => {
  318. if (res.status == 200) {
  319. this.$message.success(res.message)
  320. this.showTplModal = false
  321. this.resetSearchForm()
  322. }
  323. this.spinning = false
  324. })
  325. }
  326. },
  327. // 导出产品
  328. handleExport () {
  329. this.exportLoading = true
  330. shelfProductExport({ shelfSn: this.$route.params.sn }).then(res => {
  331. downloadExcel(res, (this.basicInfoData ? this.basicInfoData.shelfName : '') + '的产品')
  332. this.exportLoading = false
  333. })
  334. },
  335. // 导入或新增货位
  336. addHW (type) {
  337. // 导入货位
  338. if (type == 0) {
  339. this.openImportModal = true
  340. } else {
  341. // 新增货位
  342. this.nowData = this.basicInfoData
  343. this.modalType = 'add'
  344. this.openHwModal = true
  345. }
  346. },
  347. // 禁用启用弹框提示
  348. handleEnable (row) {
  349. const _this = this
  350. if (row.enableFlag == 1) {
  351. this.$confirm({
  352. title: '提示',
  353. content: '禁用后不参于盘点和补货,但是可以退货、调回,确认禁用吗?',
  354. centered: true,
  355. onOk () {
  356. _this.enableFun(row)
  357. }
  358. })
  359. } else {
  360. _this.enableFun(row)
  361. }
  362. },
  363. // 禁用启用货架
  364. enableFun (row) {
  365. const _this = this
  366. _this.spinning = true
  367. shelfProductEnable({
  368. shelfSn: this.$route.params.sn,
  369. shelfProductSn: row.shelfProductApiEntity.shelfProductSn,
  370. enableFlag: row.enableFlag == 1 ? 0 : 1
  371. }).then(res => {
  372. if (res.status == 200) {
  373. _this.$message.success(res.message)
  374. _this.$refs.table.refresh()
  375. }
  376. _this.spinning = false
  377. })
  378. },
  379. // 编辑货位
  380. editHW (row) {
  381. // 已绑定产品,不能编辑货位号,只能编辑已绑定产品的销售价、结算价、最大库容
  382. if (row.shelfProductApiEntity && row.shelfProductApiEntity.productSn) {
  383. this.handleProduct(row, 'edit')
  384. } else {
  385. // 货位没有绑定产品,仅编辑货位号
  386. this.nowData = Object.assign(this.basicInfoData, row)
  387. this.modalType = 'edit'
  388. this.openHwModal = true
  389. }
  390. },
  391. // 基本信息
  392. getDetail () {
  393. shelfDetail({ sn: this.$route.params.sn }).then(res => {
  394. if (res.status == 200) {
  395. this.basicInfoData = res.data
  396. // 获取价格权限
  397. this.getShelfPriceShow()
  398. } else {
  399. this.basicInfoData = null
  400. }
  401. })
  402. },
  403. // 删除货位
  404. handleDel (row) {
  405. const _this = this
  406. this.$confirm({
  407. title: '提示',
  408. content: '删除后无法恢复,确认删除?',
  409. centered: true,
  410. onOk () {
  411. _this.spinning = true
  412. delShelfPlaceSn({ shelfPlaceSn: row.shelfPlaceSn }).then(res => {
  413. if (res.status == 200) {
  414. _this.$message.success(res.message)
  415. _this.$refs.table.refresh()
  416. }
  417. _this.spinning = false
  418. })
  419. }
  420. })
  421. },
  422. // 更换产品
  423. handleReplace (row) {
  424. if (row.shelfProductApiEntity.qty) {
  425. this.openTipsModal = true
  426. } else {
  427. this.handleProduct(row, 'replace')
  428. }
  429. },
  430. // 更换产品/绑定产品/修改信息
  431. handleProduct (row, type) {
  432. if (row) {
  433. this.nowData = Object.assign(row, { customerSn: this.basicInfoData && this.basicInfoData.customerEntity && this.basicInfoData.customerEntity.customerSn })
  434. } else {
  435. this.nowData = null
  436. }
  437. this.modalType = type
  438. this.openModal = true
  439. },
  440. // 编辑弹框取消
  441. handleCancel () {
  442. this.modalType = null
  443. this.nowData = null
  444. this.openModal = false
  445. this.openHwModal = false
  446. },
  447. // 导入成功
  448. handleGuideOk (obj) {
  449. shelfProductBatchInsert(obj).then(res => {
  450. if (res.status == 200) {
  451. this.$refs.table.refresh(true)
  452. }
  453. })
  454. },
  455. // 编辑基本信息成功
  456. handleInfoOk () {
  457. this.getDetail()
  458. },
  459. // 重置
  460. resetSearchForm () {
  461. this.queryParam.shelfProductApiEntity.productCode = ''
  462. this.queryParam.shelfProductApiEntity.productName = ''
  463. this.$refs.table.refresh(true)
  464. },
  465. // 计算表格高度
  466. setTableH () {
  467. const tableSearchH = this.$refs.tableSearch.offsetHeight
  468. this.tableHeight = window.innerHeight - tableSearchH - 350
  469. },
  470. // 返回列表
  471. handleBack () {
  472. this.$router.push({ path: '/numsGoodsShelves/shelfSet/list' })
  473. }
  474. },
  475. mounted () {
  476. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  477. this.setTableH()
  478. this.getDetail()
  479. this.resetSearchForm()
  480. }
  481. },
  482. activated () {
  483. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  484. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  485. this.setTableH()
  486. this.getDetail()
  487. this.resetSearchForm()
  488. }
  489. }
  490. }
  491. </script>
  492. <style lang="less">
  493. .shelfSet-wrap{
  494. .store-info{
  495. margin: 0 15px;
  496. color: rgb(102, 102, 102);
  497. }
  498. .shelfSet-cont{
  499. margin-top: 10px;
  500. }
  501. }
  502. </style>