equipmentManagement.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="equipmentManagement">
  4. <!-- 搜索框 -->
  5. <div 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="5" :sm="24">
  9. <a-form-item label="设备编码">
  10. <a-input allowClear v-model.trim="queryParam.deviceCode" placeholder="请输入设备编码" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="5" :sm="24">
  14. <a-form-item label="客户名称">
  15. <storeList ref="storeList" @change="custChange"></storeList>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="5" :sm="24">
  19. <a-form-item label="所属省份">
  20. <a-select id="equipmentManagement-addrProvince" allowClear v-model="queryParam.provinceSn" placeholder="请选择省">
  21. <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
  22. </a-select>
  23. </a-form-item>
  24. </a-col>
  25. <a-col :md="5" :sm="24">
  26. <a-form-item label="启用状态">
  27. <v-select
  28. v-model="queryParam.deviceCode"
  29. ref="auditStatus"
  30. code="ENABLE_FLAG"
  31. placeholder="请选择启用状态"
  32. allowClear></v-select>
  33. </a-form-item>
  34. </a-col>
  35. <a-col :md="4" :sm="24">
  36. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="equipmentManagement-refresh">查询</a-button>
  37. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="equipmentManagement-reset">重置</a-button>
  38. </a-col>
  39. </a-row>
  40. </a-form>
  41. </div>
  42. <div class="table-operator">
  43. <a-button type="primary" class="button-error" @click="openModal = true">添加设备</a-button>
  44. </div>
  45. <!-- 列表 -->
  46. <s-table
  47. class="sTable"
  48. ref="table"
  49. size="default"
  50. rowKey="id"
  51. :columns="columns"
  52. :data="loadData"
  53. bordered>
  54. <!--是否启用 -->
  55. <template slot="isEnabled" slot-scope="text, record">
  56. <a-switch checked-children="是" un-checked-children="否" :checked="true" />
  57. </template>
  58. <!-- 操作 -->
  59. <template slot="action" slot-scope="text, record">
  60. <a-button size="small" type="link" class="button-primary" @click="handleEdit(record)">编辑</a-button>
  61. <a-button size="small" type="link" class="button-primary" @click="handleDel(record)">删除</a-button>
  62. </template>
  63. </s-table>
  64. </div>
  65. <!-- 添加设备 -->
  66. <addEquipmentModal ref="equipmentBox" :openModal="openModal" :itemId="itemId" @confirm="$refs.table.refresh(true)" @close="openModal=false" />
  67. </a-card>
  68. </template>
  69. <script>
  70. import storeList from '@/views/common/storeList.vue'
  71. import { STable, VSelect } from '@/components'
  72. import addEquipmentModal from './addEquipmentModal'
  73. import { handDeviceList, handDeviceDel } from '@/api/handDevice.js'
  74. import { getAreaCgj } from '@/api/data'
  75. export default {
  76. name: 'EquipmentManagement',
  77. components: { STable, VSelect, storeList, addEquipmentModal },
  78. data () {
  79. return {
  80. advanced: false, // 高级搜索 展开/关闭
  81. disabled: false, // 查询、重置按钮是否可操作
  82. queryParam: {
  83. dealerSn: undefined,
  84. deviceCode: '',
  85. deviceName: '',
  86. enabledFlag: undefined,
  87. provinceSn: undefined
  88. },
  89. addrProvinceList: [],
  90. openModal: false,
  91. itemId: '',
  92. columns: [
  93. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  94. { title: '设备编码', dataIndex: 'deviceCode', align: 'center', customRender: function (text) { return text || '--' } },
  95. { title: '设备名称', dataIndex: 'deviceName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  96. { title: '绑定客户', dataIndex: 'dealer.dealerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  97. { title: '所属省份', dataIndex: 'dealer.provinceName', align: 'center', customRender: function (text) { return text || '--' } },
  98. { title: '是否启用', scopedSlots: { customRender: 'isEnabled' }, align: 'center' },
  99. { title: '添加时间', dataIndex: 'createDate', align: 'center', customRender: function (text) { return text || '--' } },
  100. { title: '操作', scopedSlots: { customRender: 'action' }, align: 'center' }
  101. ],
  102. // 加载数据方法 必须为 Promise 对象
  103. loadData: parameter => {
  104. this.disabled = true
  105. return handDeviceList(Object.assign(parameter, this.queryParam)).then(res => {
  106. const data = res.data
  107. const no = (data.pageNo - 1) * data.pageSize
  108. for (var i = 0; i < data.list.length; i++) {
  109. data.list[i].no = no + i + 1
  110. }
  111. this.disabled = false
  112. return data
  113. })
  114. }
  115. }
  116. },
  117. methods: {
  118. // 获取所属省份
  119. getCityList () {
  120. getAreaCgj({ type: '2' }).then(res => {
  121. if (res.status == 200) {
  122. this.addrProvinceList = res.data || []
  123. } else {
  124. this.addrProvinceList = []
  125. }
  126. })
  127. },
  128. // 选择客户
  129. custChange (val) {
  130. this.queryParam.dealerSn = val.key
  131. },
  132. handleEdit (row) {
  133. this.itemId = row.id
  134. this.$nextTick(() => {
  135. this.openModal = true
  136. this.$refs.equipmentBox.pageInit()
  137. })
  138. },
  139. handleDel (row) {
  140. const _this = this
  141. this.$warning({
  142. title: '提示',
  143. content: '删除该设备后,所有绑定数据将被清除,并且不能继续操作。',
  144. okText: '删除',
  145. onOk () {
  146. handDeviceDel({ id: row.id }).then(res => {
  147. if (res.status == 200) {
  148. _this.$message.success(res.message)
  149. _this.resetSearchForm()
  150. }
  151. })
  152. },
  153. onCancel () {}
  154. })
  155. },
  156. // 时间 change
  157. dateChange (date) {
  158. this.queryParam.beginDate = date[0]
  159. this.queryParam.endDate = date[1]
  160. },
  161. // 重置
  162. resetSearchForm () {
  163. this.queryParam.dealerSn = undefined
  164. this.queryParam.deviceCode = ''
  165. this.queryParam.deviceName = ''
  166. this.queryParam.enabledFlag = undefined
  167. this.queryParam.provinceSn = undefined
  168. this.$refs.table.refresh(true)
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="less">
  174. .equipmentManagement{
  175. .sTable{
  176. margin-top: 10px;
  177. }
  178. }
  179. </style>