set.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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" size="small" type="link" style="margin-left: 20px;color: #39f;" @click.stop="openInfoModal = true">编辑</a-button>
  17. </template>
  18. <a-descriptions :column="3">
  19. <a-descriptions-item label="货架名称">{{ basicInfoData&&basicInfoData.shelfName || '--' }}</a-descriptions-item>
  20. <a-descriptions-item>
  21. <template slot="label">
  22. <a-tooltip placement="top">
  23. <template slot="title">
  24. <span>此数字货架,归属于您的哪一位客户。如果没有搜索到客户,请在客户管理功能中新建客户。</span>
  25. </template>
  26. 关联客户<a-icon type="question-circle" style="color: rgba(0,0,0,.65);font-size: 16px;margin-left: 2px;vertical-align: sub;cursor: pointer;" />
  27. </a-tooltip>
  28. </template>
  29. {{ (basicInfoData&&basicInfoData.customerEntity&&basicInfoData.customerEntity.customerName) || '--' }}
  30. </a-descriptions-item>
  31. <!-- <a-descriptions-item>
  32. <template slot="label">
  33. <a-tooltip placement="top">
  34. <template slot="title">
  35. 1、非铺货产品,是指不是货架上的产品<br>
  36. 2、终端会员价,对于汽修厂来说,即进货价<br>
  37. 3、如果该产品在销售单里有销售记录,则使用最近一次销售价,如果没有销售记录,则使用箭冠总公司的终端会员价
  38. </template>
  39. 价格显示<a-icon type="question-circle" style="color: rgba(0,0,0,.65);font-size: 16px;margin-left: 2px;vertical-align: sub;cursor: pointer;" />
  40. </a-tooltip>
  41. </template>
  42. 非铺货产品——{{ showPrice == '1' ? '显示': '不显示' }}价格
  43. </a-descriptions-item> -->
  44. </a-descriptions>
  45. </a-collapse-panel>
  46. </a-collapse>
  47. </a-card>
  48. <a-card size="small" :bordered="false" class="shelfSet-cont">
  49. <!-- 搜索条件 -->
  50. <div ref="tableSearch" class="table-page-search-wrapper">
  51. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  52. <a-row :gutter="15">
  53. <a-col :md="6" :sm="24">
  54. <a-form-item label="产品编码">
  55. <a-input id="shelfSet-productCode" v-model.trim="queryParam.shelfProductApiEntity.productCode" allowClear placeholder="请输入产品编码"/>
  56. </a-form-item>
  57. </a-col>
  58. <a-col :md="6" :sm="24">
  59. <a-form-item label="产品名称">
  60. <a-input id="shelfSet-productName" v-model.trim="queryParam.shelfProductApiEntity.productName" allowClear placeholder="请输入产品名称"/>
  61. </a-form-item>
  62. </a-col>
  63. <a-col :md="6" :sm="24">
  64. <span class="table-page-search-submitButtons">
  65. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="shelfSet-refresh">查询</a-button>
  66. <a-button style="margin-left: 5px" @click="resetSearchForm()" :disabled="disabled" id="shelfSet-reset">重置</a-button>
  67. </span>
  68. </a-col>
  69. </a-row>
  70. </a-form>
  71. </div>
  72. <!-- 操作按钮 -->
  73. <div class="table-operator">
  74. <a-button id="shelfSet-addHW" type="primary" class="button-error" @click="addHW(1)">新增货位</a-button>
  75. <a-button id="shelfSet-impoort" type="primary" class="button-info" @click="addHW(0)">批量导入货位</a-button>
  76. <a-button id="shelfSet-import" type="primary" class="button-error" @click="openGuideModal=true">导入绑定产品</a-button>
  77. <a-tooltip placement="top">
  78. <template slot="title">
  79. <span>如果货位还没有绑定产品,可使用此功能通过Excel批量导入</span>
  80. </template>
  81. <a-icon type="question-circle" theme="filled" style="color: rgba(0,0,0,.45);font-size: 16px;margin-left: 5px;vertical-align: middle;cursor: pointer;" />
  82. </a-tooltip>
  83. </div>
  84. <!-- 列表 -->
  85. <s-table
  86. class="sTable"
  87. ref="table"
  88. size="small"
  89. :rowKey="(record) => record.id"
  90. :columns="columns"
  91. :data="loadData"
  92. :showPagination="false"
  93. :defaultLoadData="false"
  94. bordered>
  95. <!-- 操作 -->
  96. <template slot="action" slot-scope="text, record">
  97. <a-button
  98. size="small"
  99. type="link"
  100. class="button-primary"
  101. v-if="!(record.shelfProductApiEntity&&record.shelfProductApiEntity.productSn)"
  102. @click="handleProduct(record, 'bind')"
  103. >绑定产品</a-button>
  104. <a-button
  105. size="small"
  106. type="link"
  107. class="button-primary"
  108. v-else
  109. @click="handleReplace(record)"
  110. >更换产品</a-button>
  111. <a-button
  112. size="small"
  113. type="link"
  114. class="button-primary"
  115. @click="editHW(record)"
  116. >编辑</a-button>
  117. <a-button
  118. size="small"
  119. type="link"
  120. class="button-error"
  121. v-if="!(record.shelfProductApiEntity&&record.shelfProductApiEntity.productSn)"
  122. @click="handleDel(record)"
  123. >删除</a-button>
  124. </template>
  125. </s-table>
  126. </a-card>
  127. </a-spin>
  128. <!-- 基础设置 -->
  129. <basic-info-modal :openModal="openInfoModal" :nowData="basicInfoData" @ok="handleInfoOk" @close="openInfoModal=false" />
  130. <!-- 修改信息/绑定产品/更换产品 -->
  131. <bind-product-modal :openModal="openModal" :type="modalType" :nowData="nowData" @ok="$refs.table.refresh()" @close="handleCancel" />
  132. <!-- 编辑、新增货位 -->
  133. <addHwModal :openModal="openHwModal" :type="modalType" :nowData="nowData" @ok="$refs.table.refresh()" @close="handleCancel" />
  134. <!-- 更换产品 -->
  135. <common-modal
  136. :openModal="openTipsModal"
  137. modalHtml="只有当前库存为0时,才能更换产品<br/>您可以在“货架监控”功能中将产品调回"
  138. okText="好的"
  139. :isCancel="false"
  140. @ok="openTipsModal=false"
  141. @close="openTipsModal=false" />
  142. <!-- 导入产品 -->
  143. <importGuideModal :openModal="openGuideModal" :params="{shelfSn: $route.params.sn}" @close="openGuideModal=false" @ok="handleGuideOk" />
  144. <!-- 导入货位模板 -->
  145. <importHuoweiModal :openModal="openImportModal" @close="openImportModal=false" @ok="$refs.table.refresh(true)" :shelfSn="$route.params.sn"></importHuoweiModal>
  146. </div>
  147. </template>
  148. <script>
  149. import { commonMixin } from '@/utils/mixin'
  150. import { STable, VSelect } from '@/components'
  151. import commonModal from '@/views/common/commonModal.vue'
  152. import addHwModal from './addHwModal.vue'
  153. import bindProductModal from './bindProductModal.vue'
  154. import ImportGuideModal from './importGuideModal.vue'
  155. import basicInfoModal from './basicInfoModal.vue'
  156. import importHuoweiModal from './importHuoweiModal.vue'
  157. // , getShelfPriceShow
  158. import { shelfDetail, shelfProductList, shelfProductBatchInsert, delShelfPlaceSn } from '@/api/shelf'
  159. export default {
  160. name: 'ShelfMonitoringWarehousing',
  161. components: { STable, VSelect, commonModal, bindProductModal, addHwModal, ImportGuideModal, basicInfoModal, importHuoweiModal },
  162. mixins: [commonMixin],
  163. data () {
  164. return {
  165. spinning: false,
  166. disabled: false, // 查询、重置按钮是否可操作
  167. queryParam: {
  168. shelfProductApiEntity: {
  169. productCode: '',
  170. productName: ''
  171. }
  172. },
  173. columns: [
  174. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  175. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  176. { title: '绑定产品编码', dataIndex: 'shelfProductApiEntity.productCode', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  177. { title: '绑定产品名称', dataIndex: 'shelfProductApiEntity.productName', width: '23%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  178. { title: '销售价', dataIndex: 'shelfProductApiEntity.price', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  179. { title: '结算价', dataIndex: 'shelfProductApiEntity.cost', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  180. { title: '最大库容', dataIndex: 'shelfProductApiEntity.maxQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  181. { title: '当前库存', dataIndex: 'shelfProductApiEntity.qty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  182. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  183. ],
  184. // 加载数据方法 必须为 Promise 对象
  185. loadData: parameter => {
  186. this.disabled = true
  187. this.spinning = true
  188. return shelfProductList(Object.assign(parameter, this.queryParam, { shelfSn: this.$route.params.sn })).then(res => {
  189. let data
  190. if (res.status == 200) {
  191. data = res.data
  192. for (var i = 0; i < data.length; i++) {
  193. data[i].no = i + 1
  194. }
  195. this.disabled = false
  196. }
  197. this.spinning = false
  198. return data
  199. })
  200. },
  201. basicInfoData: null,
  202. openTipsModal: false,
  203. openModal: false,
  204. nowData: null,
  205. openGuideModal: false,
  206. modalType: null,
  207. openInfoModal: false,
  208. openHwModal: false,
  209. openImportModal: false,
  210. showPrice: ''
  211. }
  212. },
  213. methods: {
  214. // 获取价格显示设置
  215. // getShelfPriceShow () {
  216. // getShelfPriceShow({ shelfSn: this.$route.params.sn }).then(res => {
  217. // if (res.status == 200) {
  218. // this.basicInfoData.showPrice = res.data.paramValue
  219. // this.showPrice = res.data.paramValue
  220. // }
  221. // })
  222. // },
  223. // 导入或新增货位
  224. addHW (type) {
  225. // 导入货位
  226. if (type == 0) {
  227. this.openImportModal = true
  228. } else {
  229. // 新增货位
  230. this.nowData = this.basicInfoData
  231. this.modalType = 'add'
  232. this.openHwModal = true
  233. }
  234. },
  235. // 编辑货位
  236. editHW (row) {
  237. // 已绑定产品,不能编辑货位号,只能编辑已绑定产品的销售价、结算价、最大库容
  238. if (row.shelfProductApiEntity && row.shelfProductApiEntity.productSn) {
  239. this.handleProduct(row, 'edit')
  240. } else {
  241. // 货位没有绑定产品,仅编辑货位号
  242. this.nowData = Object.assign(this.basicInfoData, row)
  243. this.modalType = 'edit'
  244. this.openHwModal = true
  245. }
  246. },
  247. // 基本信息
  248. getDetail () {
  249. shelfDetail({ sn: this.$route.params.sn }).then(res => {
  250. if (res.status == 200) {
  251. this.basicInfoData = res.data
  252. // this.getShelfPriceShow()
  253. } else {
  254. this.basicInfoData = null
  255. }
  256. })
  257. },
  258. // 删除货位
  259. handleDel (row) {
  260. const _this = this
  261. this.$confirm({
  262. title: '提示',
  263. content: '删除后无法恢复,确认删除?',
  264. centered: true,
  265. onOk () {
  266. _this.spinning = true
  267. delShelfPlaceSn({ shelfPlaceSn: row.shelfPlaceSn }).then(res => {
  268. if (res.status == 200) {
  269. _this.$message.success(res.message)
  270. _this.$refs.table.refresh()
  271. }
  272. _this.spinning = false
  273. })
  274. }
  275. })
  276. },
  277. // 更换产品
  278. handleReplace (row) {
  279. if (row.shelfProductApiEntity.qty) {
  280. this.openTipsModal = true
  281. } else {
  282. this.handleProduct(row, 'replace')
  283. }
  284. },
  285. // 更换产品/绑定产品/修改信息
  286. handleProduct (row, type) {
  287. if (row) {
  288. this.nowData = Object.assign(row, { customerSn: this.basicInfoData && this.basicInfoData.customerEntity && this.basicInfoData.customerEntity.customerSn })
  289. } else {
  290. this.nowData = null
  291. }
  292. this.modalType = type
  293. this.openModal = true
  294. },
  295. handleCancel () {
  296. this.modalType = null
  297. this.nowData = null
  298. this.openModal = false
  299. this.openHwModal = false
  300. },
  301. // 导入成功
  302. handleGuideOk (obj) {
  303. shelfProductBatchInsert(obj).then(res => {
  304. if (res.status == 200) {
  305. this.$refs.table.refresh(true)
  306. }
  307. })
  308. },
  309. handleInfoOk () {
  310. this.getDetail()
  311. },
  312. // 重置
  313. resetSearchForm () {
  314. this.queryParam.shelfProductApiEntity.productCode = ''
  315. this.queryParam.shelfProductApiEntity.productName = ''
  316. this.$refs.table.refresh(true)
  317. },
  318. // 返回列表
  319. handleBack () {
  320. this.$router.push({ path: '/numsGoodsShelves/shelfSet/list' })
  321. }
  322. },
  323. mounted () {
  324. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  325. this.getDetail()
  326. this.resetSearchForm()
  327. }
  328. },
  329. activated () {
  330. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  331. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  332. this.getDetail()
  333. this.resetSearchForm()
  334. }
  335. }
  336. }
  337. </script>
  338. <style lang="less">
  339. .shelfSet-wrap{
  340. .store-info{
  341. margin: 0 15px;
  342. color: rgb(102, 102, 102);
  343. }
  344. .shelfSet-cont{
  345. margin-top: 10px;
  346. }
  347. }
  348. </style>