set.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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. <span class="store-info">{{ (basicInfoData&&basicInfoData.shelfName) || '--' }}</span>
  9. </template>
  10. </a-page-header>
  11. <!-- 内容 -->
  12. <a-card size="small" :bordered="false" class="shelfSet-cont">
  13. <a-collapse :activeKey="['1']">
  14. <a-collapse-panel key="1">
  15. <template slot="header">
  16. <span>基础信息</span>
  17. <a-button icon="edit" size="small" type="link" style="margin-left: 20px;color: #39f;" @click.stop="handleInfoEdit">编辑</a-button>
  18. </template>
  19. <a-descriptions :column="3">
  20. <a-descriptions-item label="关联客户">{{ (basicInfoData&&basicInfoData.customerEntity&&basicInfoData.customerEntity.customerName) || '--' }}</a-descriptions-item>
  21. </a-descriptions>
  22. </a-collapse-panel>
  23. </a-collapse>
  24. </a-card>
  25. <a-card size="small" :bordered="false" class="shelfSet-cont">
  26. <!-- 搜索条件 -->
  27. <div ref="tableSearch" class="table-page-search-wrapper">
  28. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  29. <a-row :gutter="15">
  30. <a-col :md="6" :sm="24">
  31. <a-form-item label="产品编码">
  32. <a-input id="shelfSet-productCode" v-model.trim="queryParam.shelfProductApiEntity.productCode" allowClear placeholder="请输入产品编码"/>
  33. </a-form-item>
  34. </a-col>
  35. <a-col :md="6" :sm="24">
  36. <a-form-item label="产品名称">
  37. <a-input id="shelfSet-productName" v-model.trim="queryParam.shelfProductApiEntity.productName" allowClear placeholder="请输入产品名称"/>
  38. </a-form-item>
  39. </a-col>
  40. <a-col :md="6" :sm="24">
  41. <span class="table-page-search-submitButtons">
  42. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="shelfSet-refresh">查询</a-button>
  43. <a-button style="margin-left: 5px" @click="resetSearchForm()" :disabled="disabled" id="shelfSet-reset">重置</a-button>
  44. </span>
  45. </a-col>
  46. </a-row>
  47. </a-form>
  48. </div>
  49. <!-- 操作按钮 -->
  50. <div class="table-operator" v-if="basicInfoData&&basicInfoData.finishFlag=='0'">
  51. <a-button id="shelfSet-import" type="primary" class="button-error" @click="openGuideModal=true">导入绑定产品</a-button>
  52. <a-tooltip placement="top">
  53. <template slot="title">
  54. <span>如果货位还没有绑定产品,可使用此功能通过Excel批量导入</span>
  55. </template>
  56. <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;" />
  57. </a-tooltip>
  58. </div>
  59. <!-- 列表 -->
  60. <s-table
  61. class="sTable"
  62. ref="table"
  63. size="small"
  64. :rowKey="(record) => record.id"
  65. :columns="columns"
  66. :data="loadData"
  67. :showPagination="false"
  68. :defaultLoadData="false"
  69. bordered>
  70. <!-- 操作 -->
  71. <template slot="action" slot-scope="text, record">
  72. <a-button
  73. size="small"
  74. type="link"
  75. class="button-primary"
  76. v-if="!!(record.shelfProductApiEntity&&record.shelfProductApiEntity.productSn)"
  77. @click="handleProduct(record, 'edit')"
  78. id="shelfMonitoringList-edit-btn">修改信息</a-button>
  79. <a-button
  80. size="small"
  81. type="link"
  82. class="button-primary"
  83. v-if="!!(record.shelfProductApiEntity&&record.shelfProductApiEntity.productSn)"
  84. @click="handleReplace(record)"
  85. id="shelfMonitoringList-replace-btn">更换产品</a-button>
  86. <a-button
  87. size="small"
  88. type="link"
  89. class="button-primary"
  90. v-if="!(record.shelfProductApiEntity&&record.shelfProductApiEntity.productSn)"
  91. @click="handleProduct(record, 'bind')"
  92. id="shelfMonitoringList-bind-btn">绑定产品</a-button>
  93. </template>
  94. </s-table>
  95. </a-card>
  96. </a-spin>
  97. <!-- 修改信息/绑定产品/更换产品 -->
  98. <bind-product-modal :openModal="openModal" :type="modalType" :nowData="nowData" @ok="$refs.table.refresh()" @close="handleCancel" />
  99. <!-- 更换产品 -->
  100. <common-modal
  101. :openModal="openTipsModal"
  102. modalHtml="只有当前库存为0时,才能更换产品<br/>您可以在“货架监控”功能中将产品调回"
  103. okText="好的"
  104. :isCancel="false"
  105. @ok="openTipsModal=false"
  106. @close="openTipsModal=false" />
  107. <!-- 导入产品 -->
  108. <importGuideModal :openModal="openGuideModal" :params="{shelfSn: $route.params.sn}" @close="openGuideModal=false" @ok="handleGuideOk" />
  109. <!-- 基础设置 -->
  110. <basic-info-modal :openModal="openInfoModal" :nowData="basicInfoData" @ok="handleInfoOk" @close="openInfoModal=false" />
  111. </div>
  112. </template>
  113. <script>
  114. import { commonMixin } from '@/utils/mixin'
  115. import { STable, VSelect } from '@/components'
  116. import commonModal from '@/views/common/commonModal.vue'
  117. import bindProductModal from './bindProductModal.vue'
  118. import ImportGuideModal from './importGuideModal.vue'
  119. import basicInfoModal from './basicInfoModal.vue'
  120. import { shelfDetail, shelfProductList, shelfProductBatchInsert } from '@/api/shelf'
  121. export default {
  122. name: 'ShelfMonitoringWarehousing',
  123. components: { STable, VSelect, commonModal, bindProductModal, ImportGuideModal, basicInfoModal },
  124. mixins: [commonMixin],
  125. data () {
  126. return {
  127. spinning: false,
  128. disabled: false, // 查询、重置按钮是否可操作
  129. queryParam: {
  130. shelfProductApiEntity: {
  131. productCode: '',
  132. productName: ''
  133. }
  134. },
  135. columns: [
  136. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  137. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  138. { title: '绑定产品编码', dataIndex: 'shelfProductApiEntity.productCode', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  139. { title: '绑定产品名称', dataIndex: 'shelfProductApiEntity.productName', width: '23%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  140. { title: '销售价', dataIndex: 'shelfProductApiEntity.price', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  141. { title: '结算价', dataIndex: 'shelfProductApiEntity.cost', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  142. { title: '最大库容', dataIndex: 'shelfProductApiEntity.maxQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  143. { title: '当前库存', dataIndex: 'shelfProductApiEntity.qty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  144. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  145. ],
  146. // 加载数据方法 必须为 Promise 对象
  147. loadData: parameter => {
  148. this.disabled = true
  149. this.spinning = true
  150. return shelfProductList(Object.assign(parameter, this.queryParam, { shelfSn: this.$route.params.sn })).then(res => {
  151. let data
  152. if (res.status == 200) {
  153. data = res.data
  154. for (var i = 0; i < data.length; i++) {
  155. data[i].no = i + 1
  156. }
  157. this.disabled = false
  158. }
  159. this.spinning = false
  160. return data
  161. })
  162. },
  163. basicInfoData: null,
  164. openTipsModal: false,
  165. openModal: false,
  166. nowData: null,
  167. openGuideModal: false,
  168. modalType: null,
  169. openInfoModal: false
  170. }
  171. },
  172. methods: {
  173. // 编辑基本信息
  174. handleInfoEdit () {
  175. this.openInfoModal = true
  176. },
  177. // 基本信息
  178. getDetail () {
  179. shelfDetail({ sn: this.$route.params.sn }).then(res => {
  180. if (res.status == 200) {
  181. this.basicInfoData = res.data
  182. } else {
  183. this.basicInfoData = null
  184. }
  185. })
  186. },
  187. // 更换产品
  188. handleReplace (row) {
  189. if (row.qty) {
  190. this.openTipsModal = true
  191. } else {
  192. this.handleProduct(row, 'replace')
  193. }
  194. },
  195. // 更换产品/绑定产品/修改信息
  196. handleProduct (row, type) {
  197. if(row){
  198. this.nowData = Object.assign(row, { customerSn: this.basicInfoData&&this.basicInfoData.customerEntity&&this.basicInfoData.customerEntity.customerSn })
  199. }else{
  200. this.nowData = null
  201. }
  202. this.modalType = type
  203. this.openModal = true
  204. },
  205. handleCancel () {
  206. this.nowData = null
  207. this.openModal = false
  208. },
  209. // 导入成功
  210. handleGuideOk (obj) {
  211. shelfProductBatchInsert(obj).then(res => {
  212. if (res.status == 200) {
  213. this.$refs.table.refresh(true)
  214. }
  215. })
  216. },
  217. handleInfoOk () {
  218. this.getDetail()
  219. },
  220. // 重置
  221. resetSearchForm () {
  222. this.queryParam.shelfProductApiEntity.productCode = ''
  223. this.queryParam.shelfProductApiEntity.productName = ''
  224. this.$refs.table.refresh(true)
  225. },
  226. // 返回列表
  227. handleBack () {
  228. this.$router.push({ path: '/numsGoodsShelves/shelfSet/list' })
  229. }
  230. },
  231. mounted () {
  232. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  233. this.getDetail()
  234. this.resetSearchForm()
  235. }
  236. },
  237. activated () {
  238. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  239. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  240. this.getDetail()
  241. this.resetSearchForm()
  242. }
  243. }
  244. }
  245. </script>
  246. <style lang="less">
  247. .shelfSet-wrap{
  248. .store-info{
  249. margin: 0 15px;
  250. color: rgb(102, 102, 102);
  251. }
  252. .shelfSet-cont{
  253. margin-top: 10px;
  254. }
  255. }
  256. </style>