set.vue 18 KB

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