goodsAllocationSet.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <div class="goodsAllocationSet-page">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="goodsAllocationSet-baseInfo">
  5. <template slot="subTitle">
  6. <a href="javascript:;" @click="handleBack" id="goodsAllocationSet-handleBack">
  7. <a-icon type="left"></a-icon> 返回列表
  8. </a>
  9. <span style="margin: 0 15px;color: #666;font-weight: bold;">{{ pageInfo&&pageInfo.shelfName?pageInfo.shelfName:'--' }}</span>
  10. </template>
  11. </a-page-header>
  12. <a-card :bordered="false" size="small" class="goodsAllocationSet-baseInfo">
  13. <a-collapse :activeKey="['1']">
  14. <a-collapse-panel key="1" header="基础信息">
  15. <a-descriptions size="small" :column="3">
  16. <a-descriptions-item label="配件经销商">{{ pageInfo&&pageInfo.dealerName?pageInfo.dealerName:'--' }}</a-descriptions-item>
  17. <a-descriptions-item label="汽车修理厂">{{ pageInfo&&pageInfo.storeName?pageInfo.storeName:'--' }}</a-descriptions-item>
  18. <a-descriptions-item label="货架归属">{{ pageInfo&&pageInfo.ownerType==0?'自有':'平台' }}</a-descriptions-item>
  19. <a-descriptions-item label="货架图片" v-if="pageInfo&&pageInfo.ownerType==0">
  20. <div v-if="pageInfo && images&&images.length>0">
  21. <img :src="images[0]|| ''" width="30" height="30" class="imageUrl" @click="inited(images)" /> {{ '共'+images?images.length+'张':'' }}
  22. </div>
  23. <span v-else>--</span>
  24. </a-descriptions-item>
  25. <a-descriptions-item label="备注">{{ pageInfo&&pageInfo.remarks?pageInfo.remarks:'--' }}</a-descriptions-item>
  26. </a-descriptions>
  27. </a-collapse-panel>
  28. </a-collapse>
  29. </a-card>
  30. <a-card :bordered="false" size="small" class="pages-wrap">
  31. <div class="goodsAllocationSet-baseInfo">
  32. <a-button id="goodsAllocationSet-impoort" type="primary" class="button-info" @click="addHW(0,pageInfo)">批量导入货位</a-button>
  33. <a-button id="goodsAllocationSet-addHW" type="primary" class="button-error" @click="addHW(1,pageInfo)">新增货位</a-button>
  34. </div>
  35. <a-table
  36. class="sTable fixPagination"
  37. ref="table"
  38. size="small"
  39. :pagination="false"
  40. :columns="columns"
  41. :data-source="loadData"
  42. bordered>
  43. <template slot="status" slot-scope="text, record">
  44. <a-button size="small" type="link" id="goodsAllocationSet-handleEdit" @click="handleEdit(record)" v-if="!record.shelfProductEntity">编辑</a-button>
  45. <a-button size="small" type="link" id="goodsAllocationSet-handleDel" @click="handleDel(record)" v-if="!record.shelfProductEntity">删除</a-button>
  46. <span v-if="record.shelfProductEntity" style="display: inline-block;padding-left: 7px;">--</span>
  47. </template>
  48. </a-table>
  49. </a-card>
  50. <!-- 导入货位模板 -->
  51. <importHuoweiModal :openModal="openModal" @close="openModal=false" @refresh="getHwList" :shelfSn="shelfSn" @ok="handleOk"></importHuoweiModal>
  52. <!-- 新增货位 -->
  53. <addHWModal :openHWModal="openHWModal" @refresh="getHwList" :shelfSn="shelfSn" :nowData="itemData" @close="openHWModal=false"></addHWModal>
  54. </a-spin>
  55. </div>
  56. </template>
  57. <script>
  58. import {
  59. STable
  60. } from '@/components'
  61. import { shelfDetail, shelfHWList, delHw } from '@/api/shelf.js'
  62. import importHuoweiModal from './importHuoweiModal.vue'
  63. import addHWModal from './addHWModal.vue'
  64. export default {
  65. components: {
  66. STable, importHuoweiModal, addHWModal },
  67. data () {
  68. return {
  69. spinning: false,
  70. openModal: false, // 货位模板弹窗初始状态(批量导入)
  71. openHWModal: false, // 新增货位初始弹窗
  72. pageInfo: null,
  73. itemData: null,
  74. shelfSn: '', // 货架sn
  75. images: [], // 货架图片
  76. // 表头
  77. columns: [
  78. {
  79. title: '序号',
  80. width: '4%',
  81. align: 'center',
  82. customRender: function (text, record, index) {
  83. return index + 1
  84. }
  85. },
  86. {
  87. title: '货位号',
  88. dataIndex: 'shelfPlaceCode',
  89. width: '11%',
  90. align: 'center',
  91. customRender: function (text) {
  92. return text || '--'
  93. }
  94. },
  95. {
  96. title: '绑定产品编码',
  97. dataIndex: 'shelfProductEntity.productCode',
  98. width: '10%',
  99. align: 'center',
  100. customRender: function (text) {
  101. return text || '--'
  102. }
  103. },
  104. {
  105. title: '绑定产品名称',
  106. dataIndex: 'shelfProductEntity.productName',
  107. width: '16%',
  108. align: 'left',
  109. customRender: function (text) {
  110. return text || '--'
  111. }
  112. },
  113. {
  114. title: '创建时间',
  115. dataIndex: 'createDate',
  116. width: '18%',
  117. align: 'center',
  118. customRender: function (text) {
  119. return text || '--'
  120. },
  121. ellipsis: true
  122. },
  123. {
  124. title: '操作',
  125. width: '9%',
  126. align: 'left',
  127. scopedSlots: {
  128. customRender: 'status'
  129. }
  130. }
  131. ],
  132. loadData: []
  133. }
  134. },
  135. methods: {
  136. handleBack () {
  137. this.$router.go(-1)
  138. },
  139. // 查看图片
  140. inited (viewer) {
  141. if (viewer) {
  142. const imageUrl = []
  143. viewer.map(item => {
  144. imageUrl.push(item)
  145. })
  146. this.$viewerApi({
  147. images: imageUrl
  148. })
  149. }
  150. },
  151. // 导入或新增
  152. addHW (type, val) {
  153. this.shelfSn = val.shelfSn
  154. if (type == 0) {
  155. this.openModal = true
  156. } else {
  157. this.itemData = null
  158. this.openHWModal = true
  159. }
  160. },
  161. // 获取货位列表
  162. getHwList () {
  163. this.spinning = true
  164. this.shelfSn = this.$route.params.shelfSn
  165. shelfHWList(Object.assign({ shelfSn: this.$route.params.shelfSn, shelfProductEntity: {} })).then(res => {
  166. if (res.status == 200) {
  167. this.loadData = res.data
  168. }
  169. this.spinning = false
  170. })
  171. },
  172. // 删除
  173. handleDel (row) {
  174. const _this = this
  175. this.$confirm({
  176. title: '警告',
  177. content: '删除后无法恢复,确认删除?',
  178. centered: true,
  179. onOk () {
  180. _this.spinning = true
  181. delHw({
  182. shelfPlaceSn: row.shelfPlaceSn
  183. }).then(res => {
  184. if (res.status == 200) {
  185. _this.$message.success(res.message)
  186. _this.getHwList()
  187. }
  188. _this.spinning = false
  189. })
  190. }
  191. })
  192. },
  193. // 编辑
  194. handleEdit (row) {
  195. this.shelfSn = row.shelfSn
  196. this.itemData = row
  197. this.openHWModal = true
  198. },
  199. // 货架详情
  200. getShelfDetail () {
  201. this.spinning = true
  202. shelfDetail({
  203. shelfSn: this.$route.params.shelfSn
  204. }).then(res => {
  205. if (res.status == 200) {
  206. this.pageInfo = Object.assign({}, res.data)
  207. if (res.data.ownerType == 0 && res.data.images) {
  208. this.images = res.data.images.split(',')
  209. }
  210. } else {
  211. this.pageInfo = null
  212. }
  213. this.spinning = false
  214. })
  215. },
  216. // 货位导入成功
  217. handleOk (obj) {
  218. console.log(obj, 'obj')
  219. this.getHwList()
  220. },
  221. pageInit () {
  222. this.getShelfDetail()
  223. this.getHwList()
  224. }
  225. },
  226. mounted () {
  227. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  228. this.pageInit()
  229. }
  230. },
  231. activated () {
  232. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  233. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  234. this.pageInit()
  235. }
  236. },
  237. beforeRouteEnter (to, from, next) {
  238. next(vm => {})
  239. }
  240. }
  241. </script>
  242. <style lang="less">
  243. .goodsAllocationSet-page {
  244. position: relative;
  245. height: 100%;
  246. padding-bottom: 51px;
  247. box-sizing: border-box;
  248. .goodsAllocationSet-baseInfo {
  249. margin-bottom: 10px;
  250. }
  251. }
  252. </style>