index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <div class="dashboard-container">
  3. <div class="demo-input-size">
  4. <el-input
  5. v-model="deviceCode"
  6. size="mini"
  7. placeholder="请输入设备编号"
  8. />
  9. <el-input
  10. v-model="deviceType"
  11. size="mini"
  12. placeholder="请输入设备型号"
  13. />
  14. <el-input
  15. v-model="region"
  16. size="mini"
  17. placeholder="请输入设备地区"
  18. />
  19. <el-input
  20. v-model="address"
  21. size="mini"
  22. placeholder="请输入设备地址"
  23. />
  24. <el-date-picker
  25. v-model="gmtCreated"
  26. size="mini"
  27. type="daterange"
  28. range-separator="至"
  29. start-placeholder="设备安装开始日期"
  30. end-placeholder="设备安装结束日期"
  31. format="yyyy 年 MM 月 dd 日"
  32. value-format="yyyy-MM-dd"
  33. />
  34. <el-button type="primary" size="mini" style="float: right;" @click="search">查询</el-button>
  35. </div>
  36. <div v-show="type === '2' || type === '1,2' || type === '2,1'">
  37. <el-table
  38. :data="deviceData"
  39. style="width: 100%"
  40. >
  41. <el-table-column
  42. label="设备安装时间"
  43. prop="gmtCreated"
  44. />
  45. <el-table-column
  46. label="设备编号"
  47. prop="deviceCode"
  48. />
  49. <el-table-column
  50. label="设备尺寸"
  51. prop="deviceSize"
  52. />
  53. <el-table-column
  54. label="设备型号"
  55. prop="deviceType"
  56. />
  57. <el-table-column
  58. label="设备地区"
  59. prop="region"
  60. />
  61. <el-table-column
  62. label="设备地址"
  63. prop="address"
  64. />
  65. <el-table-column
  66. label="状态"
  67. >
  68. <template slot-scope="scope">
  69. <span>
  70. {{ scope.row.status === 'UNNORMAL' ? '不正常' : '正常' }}
  71. </span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column
  75. align="right"
  76. >
  77. <template slot-scope="scope">
  78. <el-button
  79. size="mini"
  80. style="float: left; margin: 0 10px 0 0;"
  81. @click="handleMaintainMessage(scope.$index, scope.row)"
  82. >
  83. 维护信息
  84. </el-button>
  85. <el-button
  86. v-show="scope.row.status === 'UNNORMAL'"
  87. size="mini"
  88. style="float: left; margin: 0 10px 0 0;"
  89. type="danger"
  90. @click="handleMaintain(scope.$index, scope.row)"
  91. >
  92. 立即维护
  93. </el-button>
  94. </template>
  95. </el-table-column>
  96. </el-table>
  97. </div>
  98. <div v-show="type === '0'">
  99. <el-table
  100. :data="deviceData"
  101. style="width: 100%"
  102. >
  103. <el-table-column
  104. label="设备安装时间"
  105. prop="gmtCreated"
  106. />
  107. <el-table-column
  108. label="设备编号"
  109. prop="deviceCode"
  110. />
  111. <el-table-column
  112. label="设备尺寸"
  113. prop="deviceSize"
  114. />
  115. <el-table-column
  116. label="设备型号"
  117. prop="deviceType"
  118. />
  119. <el-table-column
  120. label="设备地区"
  121. prop="region"
  122. />
  123. <el-table-column
  124. label="设备地址"
  125. prop="address"
  126. />
  127. <el-table-column
  128. align="right"
  129. >
  130. <template slot-scope="scope">
  131. <el-button
  132. size="mini"
  133. style="float: left; margin: 0 10px 0 0;"
  134. @click="handleInstall(scope.$index, scope.row)"
  135. >
  136. 安装信息
  137. </el-button>
  138. <el-button
  139. size="mini"
  140. style="float: left; margin: 0 10px 0 0;"
  141. @click="handleMaintainMessage(scope.$index, scope.row)"
  142. >
  143. 维护信息
  144. </el-button>
  145. <el-button
  146. size="mini"
  147. style="float: left; margin: 0 10px 0 0;"
  148. @click="handleUse(scope.$index, scope.row)"
  149. >
  150. 使用日志
  151. </el-button>
  152. </template>
  153. </el-table-column>
  154. </el-table>
  155. </div>
  156. <el-dialog :title="gridTile" :visible.sync="dialogTableVisible">
  157. <el-table :data="gridData">
  158. <el-table-column
  159. v-for="item in information"
  160. :key="item.label"
  161. :label="item.label"
  162. :prop="item.type"
  163. />
  164. </el-table>
  165. </el-dialog>
  166. <el-dialog
  167. title="安装信息"
  168. :visible.sync="dialogVisible"
  169. width="60%"
  170. >
  171. <div class="install">
  172. 安装日期: {{ gridInstallData.length > 0 ? gridInstallData[0].deviceLog.gmtCreated : '' }}
  173. </div>
  174. <div class="install">
  175. 安装人员: {{ gridInstallData.length > 0 ? gridInstallData[0].deviceModifier.name : '' }}
  176. </div>
  177. <div class="install">
  178. 安装地区: {{ gridInstallData.length > 0 ? gridInstallData[0].device.region : '' }}
  179. </div>
  180. <div class="install">
  181. 安装地址: {{ gridInstallData.length > 0 ? gridInstallData[0].device.address : '' }}
  182. </div>
  183. <div class="install">
  184. 备注信息: {{ gridInstallData.length > 0 ? gridInstallData[0].deviceLog.description : '' }}
  185. </div>
  186. </el-dialog>
  187. <el-dialog title="立即维护" :visible.sync="dialogFormVisible">
  188. <el-form :model="solveForm" label-width="80px">
  189. <el-form-item label="解决方案">
  190. <el-input v-model="solveForm.description" type="textarea" />
  191. </el-form-item>
  192. </el-form>
  193. <div slot="footer" class="dialog-footer">
  194. <el-button @click="dialogFormVisible = false">取 消</el-button>
  195. <el-button type="primary" @click="handSolve">确 定</el-button>
  196. </div>
  197. </el-dialog>
  198. </div>
  199. </template>
  200. <script>
  201. import { mapGetters } from 'vuex'
  202. import { getToken, getType } from '@/utils/auth'
  203. export default {
  204. name: 'Device',
  205. data() {
  206. return {
  207. dialogTableVisible: false,
  208. dialogVisible: false,
  209. gridData: [],
  210. gridInstallData: [],
  211. gridTile: '',
  212. type: getType(),
  213. uid: getToken(),
  214. information: [],
  215. deviceCode: '',
  216. deviceType: '',
  217. region: '',
  218. address: '',
  219. gmtCreated: '',
  220. dialogFormVisible: false,
  221. solveForm: {
  222. deviceCode: '',
  223. deviceId: '',
  224. opType: 'MODIFIED',
  225. description: '',
  226. status: 'NORMAL'
  227. }
  228. }
  229. },
  230. computed: {
  231. ...mapGetters(['deviceData'])
  232. },
  233. created() {
  234. if (this.type.indexOf('2') !== -1) {
  235. this.$store.dispatch('admin/getDeviceData', {
  236. modifier: this.uid
  237. })
  238. } else {
  239. this.$store.dispatch('admin/getDeviceData')
  240. }
  241. },
  242. methods: {
  243. search() {
  244. console.log(this.gmtCreated)
  245. const startTime = this.gmtCreated ? this.gmtCreated[0] : ''
  246. const endTime = this.gmtCreated ? this.gmtCreated[1] : ''
  247. if (this.type === '2' || this.type === '1,2' || this.type === '2,1') {
  248. this.$store.dispatch('admin/getDeviceData', {
  249. deviceCode: this.deviceCode,
  250. deviceType: this.deviceType,
  251. region: this.region,
  252. address: this.address,
  253. startTime,
  254. endTime,
  255. modifier: this.uid
  256. })
  257. } else {
  258. this.$store.dispatch('admin/getDeviceData', {
  259. deviceCode: this.deviceCode,
  260. deviceType: this.deviceType,
  261. region: this.region,
  262. address: this.address,
  263. startTime,
  264. endTime
  265. })
  266. }
  267. },
  268. handleInstall(index, row) {
  269. this.$store.dispatch('admin/queryLogData', {
  270. deviceId: row.id,
  271. deviceCode: row.deviceCode,
  272. opType: 'INSTALL'
  273. }).then(() => {
  274. this.gridInstallData = this.$store.getters.logData
  275. this.dialogVisible = true
  276. })
  277. },
  278. handleMaintainMessage(index, row) {
  279. this.$store.dispatch('admin/queryLogData', {
  280. deviceId: row.id,
  281. deviceCode: row.deviceCode,
  282. opType: 'MODIFIED'
  283. }).then(() => {
  284. this.gridData = this.$store.getters.logData
  285. this.gridTile = '维护信息'
  286. this.information = [{
  287. label: '报修日期',
  288. type: 'deviceLog[gmtCreated]'
  289. }, {
  290. label: '维护人员',
  291. type: 'deviceModifier[name]'
  292. }, {
  293. label: '解决日期',
  294. type: 'deviceLog[gmtCreated]'
  295. }, {
  296. label: '维护状态',
  297. type: 'deviceLog[status]'
  298. }, {
  299. label: '解决方案',
  300. type: 'deviceLog[description]'
  301. }]
  302. this.dialogTableVisible = true
  303. })
  304. },
  305. handleMaintain(index, row) {
  306. this.solveForm.deviceCode = row.deviceCode
  307. this.solveForm.deviceId = row.id
  308. this.dialogFormVisible = true
  309. },
  310. handleUse(index, row) {
  311. console.log(index, row)
  312. this.$store.dispatch('admin/queryLogData', {
  313. deviceId: row.id,
  314. deviceCode: row.deviceCode,
  315. opType: 'USE'
  316. }).then(() => {
  317. this.gridData = this.$store.getters.logData
  318. this.gridTile = '使用日志'
  319. this.information = [{
  320. label: '设备连接时间',
  321. type: 'deviceLog[gmtCreated]'
  322. }, {
  323. label: '设备连接用户',
  324. type: 'deviceLog[mobile]'
  325. }]
  326. this.dialogTableVisible = true
  327. })
  328. // this.gridData = []
  329. // this.gridData.push(row)
  330. // this.gridTile = '使用日志'
  331. // this.dialogTableVisible = true
  332. },
  333. handSolve() {
  334. this.$store.dispatch('admin/addDeviceLogMaintain', this.solveForm)
  335. this.dialogFormVisible = false
  336. }
  337. }
  338. }
  339. </script>
  340. <style lang="scss" scoped>
  341. .dashboard {
  342. &-container {
  343. margin: 30px;
  344. }
  345. &-text {
  346. font-size: 30px;
  347. line-height: 46px;
  348. }
  349. }
  350. .el-input {
  351. width: auto;
  352. }
  353. .install {
  354. margin-bottom: 10px;
  355. }
  356. </style>