list.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <a-card size="small" :bordered="false" class="shelfSetList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="货架名称">
  10. <shelfSList v-model="queryParam.shelfSn"></shelfSList>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="关联客户">
  15. <custList ref="custList" @change="custChange" :isEnabled="true"></custList>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="是否设置完成">
  20. <v-select
  21. v-model="queryParam.finishFlag"
  22. ref="finishFlag"
  23. id="shelfSetList-finishFlag"
  24. code="FLAG"
  25. placeholder="请选择"
  26. allowClear></v-select>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24" style="margin-bottom: 10px">
  30. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="shelfSetList-refresh">查询</a-button>
  31. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="shelfSetList-reset">重置</a-button>
  32. </a-col>
  33. </a-row>
  34. </a-form>
  35. </div>
  36. <!-- 提示 -->
  37. <a-alert type="info" style="margin-bottom: 10px">
  38. <div slot="message">注意:只有当数字货架的“是否设置完成”为"是",系统才会自动对该货架生成补货单,修理厂才能正常下单。</div>
  39. </a-alert>
  40. <!-- 列表 -->
  41. <s-table
  42. class="sTable fixPagination"
  43. ref="table"
  44. :style="{ height: tableHeight+84.5+'px' }"
  45. size="small"
  46. :rowKey="(record) => record.id"
  47. :columns="columns"
  48. :data="loadData"
  49. :scroll="{ y: tableHeight }"
  50. :defaultLoadData="false"
  51. bordered>
  52. <!-- 货位数量 -->
  53. <template slot="shelfPlaceNum" slot-scope="text, record">
  54. <p style="margin: 0;">
  55. <span style="color: red;">
  56. {{ record.shelfPlaceBindNum||record.shelfPlaceBindNum==0 ? record.shelfPlaceBindNum:'' }}</span> /
  57. {{ record.shelfPlaceNum }}
  58. </p>
  59. </template>
  60. <!-- 是否设置完成 -->
  61. <template slot="finishFlag" slot-scope="text, record">
  62. <a-switch
  63. checkedChildren="是"
  64. unCheckedChildren="否"
  65. v-if="record.finishFlag!=undefined"
  66. @change="changeStatus(record)"
  67. :checked="record.finishFlag == 1"
  68. />
  69. <span v-else :style="{ color: record.finishFlag == 1 ? '#00aa00' : '#999' }">
  70. {{ record.finishFlag == 1 ? '是' : (record.finishFlag!=undefined?'否':'--') }}
  71. </span>
  72. </template>
  73. <!-- 操作 -->
  74. <template slot="action" slot-scope="text, record">
  75. <a-button size="small" type="link" class="button-primary" @click="handleSet(record)">设置</a-button>
  76. </template>
  77. </s-table>
  78. </a-spin>
  79. <!-- 基础设置 -->
  80. <basic-info-modal :type="0" :openModal="openModal" :nowData="nowData" @ok="handleOk" @close="openModal=false" />
  81. </a-card>
  82. </template>
  83. <script>
  84. import { commonMixin } from '@/utils/mixin'
  85. import { STable, VSelect } from '@/components'
  86. import custList from '@/views/common/custList.vue'
  87. import shelfSList from '@/views/common/shelfList'
  88. import basicInfoModal from './basicInfoModal.vue'
  89. import { shelfList, modifFinishFlag } from '@/api/shelf'
  90. export default {
  91. components: { STable, VSelect, custList, shelfSList, basicInfoModal },
  92. mixins: [commonMixin],
  93. data () {
  94. return {
  95. spinning: false,
  96. tableHeight: 0,
  97. disabled: false, // 查询、重置按钮是否可操作
  98. queryParam: {
  99. shelfSn: undefined,
  100. customerSn: undefined,
  101. finishFlag: undefined,
  102. customerEntity: {
  103. customerName: undefined
  104. }
  105. },
  106. columns: [
  107. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  108. { title: '货架名称', dataIndex: 'shelfName', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  109. { title: '关联客户', dataIndex: 'customerEntity.customerName', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  110. { title: '货位数量', scopedSlots: { customRender: 'shelfPlaceNum' }, width: '15%', align: 'center' },
  111. { title: '是否设置完成', scopedSlots: { customRender: 'finishFlag' }, width: '20%', align: 'center' },
  112. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  113. ],
  114. // 加载数据方法 必须为 Promise 对象
  115. loadData: parameter => {
  116. this.disabled = true
  117. this.spinning = true
  118. return shelfList(Object.assign(parameter, this.queryParam)).then(res => {
  119. let data
  120. if (res.status == 200) {
  121. data = res.data
  122. const no = (data.pageNo - 1) * data.pageSize
  123. for (var i = 0; i < data.list.length; i++) {
  124. data.list[i].no = no + i + 1
  125. }
  126. this.disabled = false
  127. }
  128. this.spinning = false
  129. return data
  130. })
  131. },
  132. openModal: false,
  133. nowData: null
  134. }
  135. },
  136. methods: {
  137. // 设置/修改
  138. handleSet (row) {
  139. if (row.customerSn) {
  140. this.$router.push({ path: `/numsGoodsShelves/shelfSet/set/${row.shelfSn}` })
  141. } else {
  142. this.nowData = {
  143. shelfSn: row.shelfSn,
  144. shelfName: row.shelfName
  145. }
  146. this.openModal = true
  147. }
  148. },
  149. handleOk (data) {
  150. this.$router.push({ path: `/numsGoodsShelves/shelfSet/set/${data.shelfSn}` })
  151. },
  152. // 客户 change
  153. custChange (obj, row) {
  154. if (row) {
  155. this.queryParam.customerSn = row && row.customerSn || undefined
  156. this.queryParam.customerEntity.customerName = undefined
  157. } else {
  158. this.queryParam.customerEntity.customerName = obj || undefined
  159. this.queryParam.customerSn = undefined
  160. }
  161. },
  162. // 启用 禁用
  163. changeStatus (record) {
  164. const params = {
  165. shelfSn: record.shelfSn,
  166. finishFlag: record.finishFlag == 1 ? '0' : '1'
  167. }
  168. this.spinning = true
  169. modifFinishFlag(params).then(res => {
  170. if (res.status == 200) {
  171. this.$message.success(res.message)
  172. this.$refs.table.refresh()
  173. this.spinning = false
  174. } else {
  175. this.spinning = false
  176. }
  177. })
  178. },
  179. // 重置
  180. resetSearchForm () {
  181. this.queryParam.shelfSn = undefined
  182. this.queryParam.customerSn = undefined
  183. this.queryParam.customerEntity.customerName = undefined
  184. this.$refs.custList.resetForm()
  185. this.queryParam.finishFlag = undefined
  186. this.$refs.table.refresh(true)
  187. },
  188. setTableH () {
  189. const tableSearchH = this.$refs.tableSearch.offsetHeight
  190. this.tableHeight = window.innerHeight - tableSearchH - 235
  191. },
  192. pageInit () {
  193. const _this = this
  194. this.$nextTick(() => { // 页面渲染完成后的回调
  195. _this.setTableH()
  196. })
  197. }
  198. },
  199. mounted () {
  200. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  201. this.pageInit()
  202. this.resetSearchForm()
  203. }
  204. },
  205. watch: {
  206. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  207. this.setTableH()
  208. }
  209. },
  210. activated () {
  211. // 如果是新页签打开,则重置当前页面
  212. if (this.$store.state.app.isNewTab) {
  213. this.pageInit()
  214. this.resetSearchForm()
  215. }
  216. // 仅刷新列表,不重置页面
  217. if (this.$store.state.app.updateList) {
  218. this.pageInit()
  219. this.$refs.table.refresh()
  220. }
  221. }
  222. }
  223. </script>