set.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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. 非铺货产品——{{ basicInfoData&&basicInfoData.showPrice ? '显示': '不显示' }}价格
  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. import { shelfDetail, shelfProductList, shelfProductBatchInsert, delShelfPlaceSn } from '@/api/shelf'
  158. export default {
  159. name: 'ShelfMonitoringWarehousing',
  160. components: { STable, VSelect, commonModal, bindProductModal, addHwModal, ImportGuideModal, basicInfoModal, importHuoweiModal },
  161. mixins: [commonMixin],
  162. data () {
  163. return {
  164. spinning: false,
  165. disabled: false, // 查询、重置按钮是否可操作
  166. queryParam: {
  167. shelfProductApiEntity: {
  168. productCode: '',
  169. productName: ''
  170. }
  171. },
  172. columns: [
  173. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  174. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  175. { title: '绑定产品编码', dataIndex: 'shelfProductApiEntity.productCode', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  176. { title: '绑定产品名称', dataIndex: 'shelfProductApiEntity.productName', width: '23%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  177. { title: '销售价', dataIndex: 'shelfProductApiEntity.price', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  178. { title: '结算价', dataIndex: 'shelfProductApiEntity.cost', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  179. { title: '最大库容', dataIndex: 'shelfProductApiEntity.maxQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  180. { title: '当前库存', dataIndex: 'shelfProductApiEntity.qty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  181. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  182. ],
  183. // 加载数据方法 必须为 Promise 对象
  184. loadData: parameter => {
  185. this.disabled = true
  186. this.spinning = true
  187. return shelfProductList(Object.assign(parameter, this.queryParam, { shelfSn: this.$route.params.sn })).then(res => {
  188. let data
  189. if (res.status == 200) {
  190. data = res.data
  191. for (var i = 0; i < data.length; i++) {
  192. data[i].no = i + 1
  193. }
  194. this.disabled = false
  195. }
  196. this.spinning = false
  197. return data
  198. })
  199. },
  200. basicInfoData: null,
  201. openTipsModal: false,
  202. openModal: false,
  203. nowData: null,
  204. openGuideModal: false,
  205. modalType: null,
  206. openInfoModal: false,
  207. openHwModal: false,
  208. openImportModal: false
  209. }
  210. },
  211. methods: {
  212. // 导入或新增货位
  213. addHW (type) {
  214. // 导入货位
  215. if (type == 0) {
  216. this.openImportModal = true
  217. } else {
  218. // 新增货位
  219. this.nowData = this.basicInfoData
  220. this.modalType = 'add'
  221. this.openHwModal = true
  222. }
  223. },
  224. // 编辑货位
  225. editHW (row) {
  226. // 已绑定产品,不能编辑货位号,只能编辑已绑定产品的销售价、结算价、最大库容
  227. if (row.shelfProductApiEntity && row.shelfProductApiEntity.productSn) {
  228. this.handleProduct(row, 'edit')
  229. } else {
  230. // 货位没有绑定产品,仅编辑货位号
  231. this.nowData = Object.assign(this.basicInfoData, row)
  232. this.modalType = 'edit'
  233. this.openHwModal = true
  234. }
  235. },
  236. // 基本信息
  237. getDetail () {
  238. shelfDetail({ sn: this.$route.params.sn }).then(res => {
  239. if (res.status == 200) {
  240. this.basicInfoData = res.data
  241. } else {
  242. this.basicInfoData = null
  243. }
  244. })
  245. },
  246. // 删除货位
  247. handleDel (row) {
  248. const _this = this
  249. this.$confirm({
  250. title: '提示',
  251. content: '删除后无法恢复,确认删除?',
  252. centered: true,
  253. onOk () {
  254. _this.spinning = true
  255. delShelfPlaceSn({ shelfPlaceSn: row.shelfPlaceSn }).then(res => {
  256. if (res.status == 200) {
  257. _this.$message.success(res.message)
  258. _this.$refs.table.refresh()
  259. }
  260. _this.spinning = false
  261. })
  262. }
  263. })
  264. },
  265. // 更换产品
  266. handleReplace (row) {
  267. if (row.shelfProductApiEntity.qty) {
  268. this.openTipsModal = true
  269. } else {
  270. this.handleProduct(row, 'replace')
  271. }
  272. },
  273. // 更换产品/绑定产品/修改信息
  274. handleProduct (row, type) {
  275. if (row) {
  276. this.nowData = Object.assign(row, { customerSn: this.basicInfoData && this.basicInfoData.customerEntity && this.basicInfoData.customerEntity.customerSn })
  277. } else {
  278. this.nowData = null
  279. }
  280. this.modalType = type
  281. this.openModal = true
  282. },
  283. handleCancel () {
  284. this.modalType = null
  285. this.nowData = null
  286. this.openModal = false
  287. this.openHwModal = false
  288. },
  289. // 导入成功
  290. handleGuideOk (obj) {
  291. shelfProductBatchInsert(obj).then(res => {
  292. if (res.status == 200) {
  293. this.$refs.table.refresh(true)
  294. }
  295. })
  296. },
  297. handleInfoOk () {
  298. this.getDetail()
  299. },
  300. // 重置
  301. resetSearchForm () {
  302. this.queryParam.shelfProductApiEntity.productCode = ''
  303. this.queryParam.shelfProductApiEntity.productName = ''
  304. this.$refs.table.refresh(true)
  305. },
  306. // 返回列表
  307. handleBack () {
  308. this.$router.push({ path: '/numsGoodsShelves/shelfSet/list' })
  309. }
  310. },
  311. mounted () {
  312. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  313. this.getDetail()
  314. this.resetSearchForm()
  315. }
  316. },
  317. activated () {
  318. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  319. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  320. this.getDetail()
  321. this.resetSearchForm()
  322. }
  323. }
  324. }
  325. </script>
  326. <style lang="less">
  327. .shelfSet-wrap{
  328. .store-info{
  329. margin: 0 15px;
  330. color: rgb(102, 102, 102);
  331. }
  332. .shelfSet-cont{
  333. margin-top: 10px;
  334. }
  335. }
  336. </style>