equipment.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <a-card :bordered="false" class="equipment-table-page-search-wrapper">
  3. <div class="equipment-searchForm">
  4. <a-form layout="inline" v-bind="formItemLayout" @keyup.enter.native="$refs.table.refresh(true)">
  5. <a-row :gutter="48">
  6. <a-col :span="6">
  7. <a-form-item label="设备编号" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  8. <a-input id="equipment-srcDeviceCode" allowClear :maxLength="120" v-model="queryParam.srcDeviceCode" placeholder="请输入设备编号" />
  9. </a-form-item>
  10. </a-col>
  11. <a-col :span="6">
  12. <a-form-item label="网点名称" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  13. <a-input id="equipment-stationName" allowClear :maxLength="30" v-model="queryParam.stationName" placeholder="请输入网点名称" />
  14. </a-form-item>
  15. </a-col>
  16. <a-col :span="6">
  17. <a-form-item label="箱体类型" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  18. <a-select
  19. id="equipment-deviceTypeNo"
  20. allowClear
  21. show-search
  22. option-filter-prop="children"
  23. placeholder="请选择箱体类型"
  24. v-model="queryParam.deviceTypeNo">
  25. <a-select-option v-for="(item,index) in deviceTypeList" :key="index" :value="item.deviceTypeNo">{{ item.name }}</a-select-option>
  26. </a-select>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :span="6">
  30. <a-form-item label="内置箱体数" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  31. <v-select
  32. v-model="queryParam.boxNum"
  33. ref="boxNum"
  34. id="equipment-boxNum"
  35. code="BOX_NUM"
  36. placeholder="请选择内置箱体数"
  37. allowClear></v-select>
  38. </a-form-item>
  39. </a-col>
  40. <a-col :span="6">
  41. <a-form-item label="设备状态" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  42. <v-select
  43. v-model="queryParam.state"
  44. ref="state"
  45. id="equipment-state"
  46. code="ENABLE_FLAG"
  47. placeholder="请选择设备状态"
  48. allowClear></v-select>
  49. </a-form-item>
  50. </a-col>
  51. <a-col :span="6">
  52. <a-form-item label="工作状态" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  53. <a-select id="equipment-onlineFlag" allowClear placeholder="请选择工作状态" v-model="queryParam.onlineFlag" >
  54. <a-select-option v-for="(item,index) in onlineFlagList" :key="index" :value="item.value">{{ item.name }}</a-select-option>
  55. </a-select>
  56. </a-form-item>
  57. </a-col>
  58. <a-col :span="6">
  59. <a-button class="handle-btn serach-btn" id="equipment-btn-serach" type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  60. <a-button class="handle-btn" type="" id="equipment-btn-reset" @click="handleReset">重置</a-button>
  61. </a-col>
  62. </a-row>
  63. </a-form>
  64. </div>
  65. <!-- 合计 -->
  66. <div class="total">
  67. <a-icon type="info-circle" class="iconImg" />
  68. <strong>总计:</strong><span v-model="orderTotal">{{ orderTotal || 0 }} 条</span>
  69. </div>
  70. <s-table
  71. ref="table"
  72. size="default"
  73. :rowKey="(record) => record.id"
  74. :columns="columns"
  75. :data="loadData"
  76. bordered>
  77. <!-- 设备状态 -->
  78. <template slot="onlineFlag" slot-scope="text, record">
  79. <span :class="record.onlineFlag==0 ? 'red' : record.onlineFlag==1 ? 'green' : ''">{{ record.onlineFlag == 0 ? '离线' : record.onlineFlag == 1 ? '在线' : '--' }}</span>
  80. </template>
  81. <!-- 工作状态 -->
  82. <template slot="state" slot-scope="text, record">
  83. <span :class="record.state==0 ? 'red' : record.state==1 ? 'green' : ''">{{ record.state == 0 ? '已禁用' : record.state == 1 ? '已启用' : '--' }}</span>
  84. </template>
  85. <!-- 操作 -->
  86. <template slot="action" slot-scope="text, record">
  87. <a-button
  88. v-if="$hasPermissions('B_equipment_log')"
  89. type="primary"
  90. class="btn-edit-s"
  91. id="equipment-log-btn"
  92. @click="checkLog(record)">掉线日志</a-button>
  93. <span v-else>--</span>
  94. </template>
  95. </s-table>
  96. <!-- 掉线日志 -->
  97. <equipment-log-modal :openModal="openLogModal" :srcDeviceCode="srcDeviceCode" @close="closeModal" />
  98. </a-card>
  99. </template>
  100. <script>
  101. import { STable, VSelect } from '@/components'
  102. import equipmentLogModal from './logModal.vue'
  103. import { deviceList } from '@/api/device'
  104. import { deviceTypeListQuery } from '@/api/boxSetting'
  105. export default {
  106. name: 'Equipment',
  107. components: { STable, VSelect, equipmentLogModal },
  108. data () {
  109. return {
  110. formItemLayout: {
  111. labelCol: { span: 7 },
  112. wrapperCol: { span: 17 }
  113. },
  114. // 查询参数
  115. queryParam: {
  116. srcDeviceCode: '', // 设备编号
  117. stationName: '', // 网点名称
  118. deviceTypeNo: undefined, // 箱体类型
  119. boxNum: undefined, // 内置箱体数
  120. onlineFlag: undefined, // 设备状态
  121. state: undefined // 工作状态
  122. },
  123. // 表头
  124. columns: [
  125. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  126. { title: '网点名称', dataIndex: 'stationName', width: 200, align: 'center' },
  127. { title: '地址', dataIndex: 'stationAddress', width: 200, align: 'center' },
  128. { title: '设备编号', dataIndex: 'srcDeviceCode', width: 200, align: 'center' },
  129. { title: '箱体类型', dataIndex: 'deviceTypeName', width: 200, align: 'center' },
  130. { title: '内置箱体数', dataIndex: 'boxNum', width: 200, align: 'center' },
  131. { title: '版本', dataIndex: 'boxVersion', width: 200, align: 'center' },
  132. { title: '设备状态', scopedSlots: { customRender: 'onlineFlag' }, width: 150, align: 'center' },
  133. { title: '工作状态', scopedSlots: { customRender: 'state' }, width: 150, align: 'center' },
  134. { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center' }
  135. ],
  136. // 加载数据方法 必须为 Promise 对象
  137. loadData: parameter => {
  138. return deviceList(Object.assign(parameter, this.queryParam)).then(res => {
  139. if (res.status == 200) {
  140. const no = (res.data.pageNo - 1) * res.data.pageSize
  141. this.orderTotal = res.data.count
  142. for (let i = 0; i < res.data.list.length; i++) {
  143. const _item = res.data.list[i]
  144. _item.no = no + i + 1
  145. }
  146. return res.data
  147. }
  148. })
  149. },
  150. orderTotal: '', // 合计开单数量
  151. openLogModal: false, // 掉线日志 弹框
  152. srcDeviceCode: null, // 设备编号
  153. onlineFlagList: [ // 设备状态 下拉数据
  154. { name: '在线', value: '1' },
  155. { name: '离线', value: '0' }
  156. ],
  157. deviceTypeList: [] // 箱体类型 下拉数据
  158. }
  159. },
  160. methods: {
  161. // 重置
  162. handleReset () {
  163. this.queryParam.srcDeviceCode = ''
  164. this.queryParam.stationName = ''
  165. this.queryParam.deviceTypeNo = undefined
  166. this.queryParam.boxNum = undefined
  167. this.queryParam.onlineFlag = undefined
  168. this.queryParam.state = undefined
  169. this.$refs.table.refresh(true)
  170. },
  171. // 查看掉线日志
  172. checkLog (row) {
  173. this.srcDeviceCode = row ? row.srcDeviceCode : null
  174. this.openLogModal = true
  175. },
  176. closeModal () {
  177. this.srcDeviceCode = null
  178. this.openLogModal = false
  179. },
  180. // 获取箱体类型下拉数据
  181. getDeviceType () {
  182. deviceTypeListQuery({}).then(res => {
  183. if (res.status == 200) {
  184. this.deviceTypeList = res.data
  185. } else {
  186. this.deviceTypeList = []
  187. }
  188. })
  189. }
  190. },
  191. beforeRouteEnter (to, from, next) {
  192. next(vm => {
  193. vm.getDeviceType()
  194. })
  195. }
  196. }
  197. </script>
  198. <style lang="less" scoped>
  199. .equipment-table-page-search-wrapper{
  200. .equipment-searchForm{
  201. .ant-form-inline .ant-form-item{
  202. width: 100%;
  203. }
  204. // 搜索框的下间距
  205. .ant-form-item {
  206. margin-bottom: 10px;
  207. }
  208. .handle-btn{
  209. margin-top: 4px;
  210. }
  211. .serach-btn{
  212. margin-right: 10px;
  213. }
  214. }
  215. .actionBtn {
  216. font-size: 20px;
  217. padding: 0 10px;
  218. }
  219. // 合计
  220. .total {
  221. margin: 15px 0 25px;
  222. width: 100%;
  223. background-color: #e6f7ff;
  224. border: 1px solid #91d5ff;
  225. padding: 8px 15px 8px 27px;
  226. border-radius: 4px;
  227. .iconImg {
  228. color: #1890FF;
  229. margin-right: 10px;
  230. }
  231. }
  232. .blue {
  233. color: #1890FF;
  234. }
  235. .green {
  236. color: #16b50e;
  237. }
  238. .red {
  239. color: red;
  240. }
  241. }
  242. </style>