多媒体信息发布平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

530 lines
17 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索栏 -->
  4. <div class="head-container">
  5. <el-row type="flex">
  6. <el-col :span="20" class="col_flex">
  7. <div class="form_item">
  8. <span>设备ID:</span>
  9. <el-input v-model="queryInfo.device_id" clearable size="small" placeholder="请输入设备ID" style="width: 200px" class="filter-item" @keyup.enter.native="getStartUpList" @blur="getStartUpList" />
  10. </div>
  11. <div class="form_item">
  12. <span>设备名称</span>
  13. <el-input v-model="queryInfo.device_name" clearable size="small" placeholder="请输入设备名称" style="width: 200px" class="filter-item" @keyup.enter.native="getStartUpList" @blur="getStartUpList" />
  14. </div>
  15. </el-col>
  16. <el-col class="page_add" :span="4">
  17. <el-button class="table_add clear_btn" plain :disabled="clearBtnDisabled" @click="removeStartUp(sels)">清空</el-button>
  18. </el-col>
  19. </el-row>
  20. </div>
  21. <!-- 配置开关机列表 -->
  22. <el-row :gutter="15">
  23. <el-col>
  24. <el-table style="width: 100%;" :data="startUpList" :header-cell-style="{ background: '#3a8aeb', color: '#fff' }" @selection-change="handleSelectionChange">
  25. <el-table-column type="selection" width="55" />
  26. <el-table-column prop="device_id" label="设备ID" align="center" />
  27. <el-table-column prop="device_account" label="设备账号" align="center" width="150" />
  28. <el-table-column prop="device_name" label="设备名称" align="center" />
  29. <el-table-column label="设备方向" align="center">
  30. <template slot-scope="{row}">
  31. <div>{{ row.device_direction==1? '竖屏' : '横屏' }}</div>
  32. </template>
  33. </el-table-column>
  34. <el-table-column prop="period" label="配置周期" align="center" width="300">
  35. <template slot-scope="{row}">
  36. <div v-show="row.open_setting">{{ row.open_setting==1? '每天 - 开机 '+row.open_time :'每周'+setWeekly(row.open_weekly)+'开机'+row.open_time }}</div>
  37. <div v-show="row.open_setting">{{ row.close_setting==1?'每天 - 关机'+row.close_time :'每周'+setWeekly(row.close_weekly)+'关机'+row.close_time }}</div>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="启动画面" align="center">
  41. <template slot-scope="{row}">
  42. <el-image v-show="row.startup_screen" class="cover_img" :src="row.startup_screen" />
  43. </template>
  44. </el-table-column>
  45. <el-table-column prop="update_time" label="创建时间" align="center" width="200">
  46. <template slot-scope="{row}">
  47. <div>{{ row.update_time | parseTime }}</div>
  48. </template>
  49. </el-table-column>
  50. <el-table-column fixed="right" label="操作" align="center" width="120">
  51. <template slot-scope="scope">
  52. <el-button type="primary" class="edit_btn" @click="editFormData(scope.row)">编辑</el-button>
  53. <el-button type="info" class="record_btn">记录</el-button>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. <el-pagination style="margin-top: 20px;" background :current-page="queryInfo.page" :total="total" :page-size="queryInfo.size" :pager-count="7" :page-sizes="[3, 5, 10]" layout="prev, pager, next, jumper,->,sizes,total" @current-change="getStartUpList" @size-change="handleSizeChange" />
  58. </el-col>
  59. </el-row>
  60. <!-- 编辑设备 -->
  61. <div class="layer device_layer">
  62. <el-dialog title="编辑" :close-on-click-modal="false" :show-close="false" :visible.sync="addFromVisible" width="880px">
  63. <el-form ref="form" :model="form">
  64. <div class="setting_item">
  65. <h4>开机时间</h4>
  66. <div class="setting_cont">
  67. <span>设置时间</span>
  68. <div>
  69. <el-form-item
  70. prop="open_setting"
  71. :rules="[
  72. { required: true, message: '请选择开机时间', trigger: 'change' },
  73. ]"
  74. :class="{'no_margin': form.open_setting === 2}"
  75. >
  76. <el-radio-group v-model="form.open_setting" @change="clearCheckbox()">
  77. <el-radio :label="1" value="everyday">每天</el-radio>
  78. <el-radio :label="2" value="weekly">每周</el-radio>
  79. </el-radio-group>
  80. </el-form-item>
  81. <el-form-item
  82. v-if="form.open_setting === 2"
  83. :class="{'weekly_margin': form.open_setting === 2}"
  84. prop="open_weekly"
  85. :rules="[
  86. { required: true, message: '请选择每周开机时间', trigger: 'change' },
  87. ]"
  88. >
  89. <el-checkbox-group v-model="selectOpenWeekly">
  90. <el-checkbox v-for="item in weeklyList" :key="item.id" :label="item.id" :value="item.id" name="type">{{ item.name }}</el-checkbox>
  91. </el-checkbox-group>
  92. </el-form-item>
  93. <el-form-item
  94. prop="open_time"
  95. :rules="[
  96. {type: 'string', required: true, message: '请选择具体开机时间', trigger: 'change' },
  97. ]"
  98. >
  99. <el-time-picker
  100. v-model="form.open_time"
  101. :picker-options="{
  102. selectableRange: '00:00:00 - 23:59:59'
  103. }"
  104. placeholder="任意时间点"
  105. value-format="HH:mm:ss"
  106. />
  107. </el-form-item>
  108. </div>
  109. </div>
  110. </div>
  111. <div class="setting_item">
  112. <h4>关机时间</h4>
  113. <div class="setting_cont">
  114. <span>设置时间</span>
  115. <div>
  116. <el-form-item
  117. prop="close_setting"
  118. :rules="[
  119. {required: true, message: '请选择关机时间', trigger: 'change' },
  120. ]"
  121. :class="{'no_margin': form.close_setting === 2}"
  122. >
  123. <el-radio-group v-model="form.close_setting" @change="clearCheckbox()">
  124. <el-radio :label="1" value="everyday">每天</el-radio>
  125. <el-radio :label="2" value="weekly">每周</el-radio>
  126. </el-radio-group>
  127. </el-form-item>
  128. <el-form-item
  129. v-if="form.close_setting === 2"
  130. :class="{'weekly_margin': form.close_setting === 2}"
  131. prop="close_weekly"
  132. :rules="[
  133. { required: true, message: '请选择每周关机时间', trigger: 'change' },
  134. ]"
  135. >
  136. <el-checkbox-group v-model="selectCloseweekly">
  137. <el-checkbox v-for="item in weeklyList" :key="item.id" :label="item.id" :value="item.id" name="type">{{ item.name }}</el-checkbox>
  138. </el-checkbox-group>
  139. </el-form-item>
  140. <el-form-item
  141. prop="close_time"
  142. :rules="[
  143. {type: 'string', required: true, message: '请选择具体关机时间', trigger: 'change' },
  144. ]"
  145. >
  146. <el-time-picker
  147. v-model="form.close_time"
  148. :picker-options="{
  149. selectableRange: '00:00:00 - 23:59:59'
  150. }"
  151. placeholder="任意时间点"
  152. value-format="HH:mm:ss"
  153. />
  154. </el-form-item>
  155. </div>
  156. </div>
  157. </div>
  158. <div class="setting_item">
  159. <h4>设备方向</h4>
  160. <div class="setting_cont">
  161. <span>设备方向</span>
  162. <el-form-item
  163. prop="device_direction_name"
  164. :rules="[
  165. { required: true, message: '请选择具体设备方向', trigger: 'change' },
  166. ]"
  167. >
  168. <el-select v-model="form.device_direction_name" size="small" class="filter-item" value-key="name" @change="selectDirection">
  169. <el-option v-for="item in deviceData" :key="item.key" :label="item.name" :value="item" />
  170. </el-select>
  171. </el-form-item>
  172. </div>
  173. </div>
  174. <div class="setting_item">
  175. <h4>启动画面</h4>
  176. <!-- action="https://jsonplaceholder.typicode.com/posts/" -->
  177. <div class="setting_cont upload_img">
  178. <el-form-item prop="startup_screen">
  179. <UploadCover ref="childUpload" />
  180. </el-form-item>
  181. </div>
  182. </div>
  183. </el-form>
  184. <div slot="footer" class="dialog-footer">
  185. <el-button type="primary" round @click="submitForm('form')"> </el-button>
  186. <el-button round @click="resetForm('form')"> </el-button>
  187. </div>
  188. </el-dialog>
  189. </div>
  190. </div>
  191. </template>
  192. <script>
  193. import UploadCover from '../components/upload_cover.vue'
  194. import { reqStartUpList, reqEditStartUp, reqClearStartUp } from '@/api/device/startUpList.js'
  195. import { parseTime } from '@/utils/index.js'
  196. export default {
  197. name: 'DeviceConfig',
  198. components: { UploadCover },
  199. filters: {
  200. parseTime(time, cFormat) {
  201. return parseTime(time, cFormat)
  202. }
  203. },
  204. data() {
  205. return {
  206. query: {
  207. blurry: ''
  208. },
  209. // 获取开关机列表的参数
  210. queryInfo: {
  211. device_id: '',
  212. device_name: '',
  213. is_state: '',
  214. page: 1,
  215. size: 10
  216. },
  217. total: 0,
  218. // 开关机列表的数据
  219. startUpList: [],
  220. form: {
  221. device_direction: null,
  222. device_direction_name: null,
  223. device_id: '',
  224. open_setting: null, // 开机状态的每天和每周
  225. close_setting: null, // 关机状态的每天和每周
  226. open_time: '', // 具体的开机时间
  227. close_time: '', // 具体的关机时间
  228. startup_screen: '', // 启动画面的图片
  229. open_weekly: [],
  230. close_weekly: []
  231. },
  232. selectOpenWeekly: [], // 选中的开机每周状态
  233. selectCloseweekly: [], // 选中的关机机每周状态
  234. addFromVisible: false,
  235. // 被选中的行
  236. sels: [],
  237. clearBtnDisabled: true,
  238. deviceData: [{ key: '1', name: '竖屏' }, { key: '2', name: '横屏' }],
  239. weeklyList: [
  240. {
  241. id: '0',
  242. name: '周日'
  243. },
  244. {
  245. id: '1',
  246. name: '周一'
  247. },
  248. {
  249. id: '2',
  250. name: '周二'
  251. },
  252. {
  253. id: '3',
  254. name: '周三'
  255. },
  256. {
  257. id: '4',
  258. name: '周四'
  259. },
  260. {
  261. id: '5',
  262. name: '周五'
  263. },
  264. {
  265. id: '6',
  266. name: '周六'
  267. }
  268. ]
  269. }
  270. },
  271. computed: {
  272. // 将字符串渲染成汉字显示到页面
  273. setWeekly() {
  274. const a = {
  275. 0: '日',
  276. 1: '一',
  277. 2: '二',
  278. 3: '三',
  279. 4: '四',
  280. 5: '五',
  281. 6: '六'
  282. }
  283. return function(str) {
  284. if (str) {
  285. return str.split(',').map(i => a[i]).join('/')
  286. }
  287. }
  288. }
  289. },
  290. watch: {},
  291. mounted() {
  292. this.getStartUpList()
  293. },
  294. methods: {
  295. // 获取开关机列表
  296. getStartUpList() {
  297. // this.queryInfo.page = pager
  298. const params = this.queryInfo
  299. reqStartUpList(params).then(res => {
  300. if (res.code == 200) {
  301. this.startUpList = res.data.content
  302. this.total = res.data.totalElements
  303. this.queryInfo.size = res.data.size
  304. } else {
  305. return this.$message.error('获取设备列表失败!')
  306. }
  307. })
  308. },
  309. // 编辑开关机
  310. editFormData(row) {
  311. this.addFromVisible = true
  312. this.form.device_id = row.device_id
  313. this.form.open_setting = row.open_setting
  314. this.form.close_setting = row.close_setting
  315. this.form.open_time = row.open_time
  316. this.form.close_time = row.close_time
  317. this.form.startup_screen = row.startup_screen
  318. this.form.open_weekly = row.open_weekly
  319. if (row.open_weekly) {
  320. this.selectOpenWeekly = row.open_weekly.split(',')
  321. }
  322. this.form.close_weekly = row.close_weekly
  323. if (row.close_weekly) {
  324. this.selectCloseweekly = row.close_weekly.split(',')
  325. }
  326. this.form.device_direction_name = row.device_direction == 1 ? '竖屏' : '横屏'
  327. this.form.device_direction = row.device_direction
  328. this.$nextTick(() => {
  329. this.$refs.childUpload.imageUrl = this.form.startup_screen
  330. })
  331. },
  332. // 每天/每周切换的情况下数据处理
  333. clearCheckbox() {
  334. if (this.form.open_setting === 1) {
  335. this.open_weekly = []
  336. this.form.open_weekly = null
  337. }
  338. if (this.form.close_setting === 1) {
  339. this.close_weekly = []
  340. this.form.close_weekly = null
  341. }
  342. },
  343. // 选择设备方向处理
  344. selectDirection(selVal) {
  345. console.log(selVal)
  346. this.form.device_direction = selVal.key
  347. this.form.device_direction_name = selVal.name
  348. },
  349. // 重置表单数据
  350. resetForm(formName) {
  351. this.addFromVisible = false
  352. this.$refs[formName].resetFields()
  353. },
  354. // 提交表单数据
  355. submitForm(formName) {
  356. this.form.startup_screen = this.$refs.childUpload.imageUrl
  357. if (this.form.open_setting === 2) {
  358. this.form.open_weekly = this.selectOpenWeekly.join(',')
  359. }
  360. if (this.form.close_setting === 2) {
  361. this.form.close_weekly = this.selectCloseweekly.join(',')
  362. }
  363. this.$refs[formName].validate(valid => {
  364. if (valid) {
  365. const params = {
  366. close_setting: this.form.close_setting,
  367. close_time: this.form.close_time,
  368. close_weekly: this.form.close_weekly,
  369. device_id: this.form.device_id,
  370. open_setting: this.form.open_setting,
  371. open_time: this.form.open_time,
  372. open_weekly: this.form.open_weekly,
  373. device_direction: this.form.device_direction,
  374. startup_screen: this.form.startup_screen
  375. }
  376. console.log(params)
  377. reqEditStartUp(params).then(res => {
  378. if (res.code == 200) {
  379. this.$message({
  380. type: 'success',
  381. message: '修改设备成功'
  382. })
  383. this.addFromVisible = false
  384. this.getStartUpList(this.queryInfo.page)
  385. }
  386. })
  387. } else {
  388. console.log('error submit!!')
  389. return false
  390. }
  391. })
  392. },
  393. // 列表多选操作 - 清空btn状态
  394. // 单选单个复选框
  395. handleSelectionChange(sels) {
  396. this.sels = sels
  397. if (sels.length > 0) {
  398. this.clearBtnDisabled = false
  399. } else {
  400. this.clearBtnDisabled = true
  401. }
  402. },
  403. // 清空
  404. removeStartUp(rows) {
  405. const ids = []
  406. rows.forEach(item => {
  407. ids.push(item.device_id)
  408. })
  409. // console.log(ids)
  410. this.$confirm('确定要清空选中的配置周期和启动画面吗?', '提示', {
  411. confirmButtonText: '确定',
  412. cancelButtonText: '取消',
  413. type: 'warning'
  414. }).then(() => {
  415. const params = {
  416. ids
  417. }
  418. reqClearStartUp(params).then(res => {
  419. console.log(res)
  420. if (res.code == 200) {
  421. this.$message({
  422. message: '清空成功',
  423. type: 'success'
  424. })
  425. this.getStartUpList(this.startUpList.length > 1 ? this.queryInfo.page : this.queryInfo.page - 1)
  426. }
  427. }).catch(() => {
  428. this.$message({
  429. message: '清空失败',
  430. type: 'info'
  431. })
  432. })
  433. })
  434. },
  435. // 每条显示数据改变时的事件
  436. handleSizeChange(size) {
  437. // 整理参数
  438. this.queryInfo.size = size
  439. this.getStartUpList()
  440. }
  441. }
  442. }
  443. </script>
  444. <style lang="scss" scoped>
  445. .setting_btn {
  446. margin-right: 10px;
  447. }
  448. .clear_btn {
  449. color: #3a8aeb;
  450. border-color: #3a8aeb;
  451. }
  452. .cover_img {
  453. width: 65px;
  454. }
  455. .device_layer {
  456. ::v-deep .el-dialog__body {
  457. padding: 0 20px;
  458. }
  459. .setting_item {
  460. padding-top: 24px;
  461. color: #333;
  462. h4 {
  463. font-size: 16px;
  464. margin-bottom: 10px;
  465. }
  466. .setting_cont {
  467. display: flex;
  468. span {
  469. display: block;
  470. width: 80px;
  471. line-height: 32px;
  472. }
  473. .no_margin {
  474. margin: 0;
  475. }
  476. .weekly_margin {
  477. margin-bottom: 6px;
  478. ::v-deep .el-form-item__error {
  479. top: 70%;
  480. }
  481. }
  482. ::v-deep .el-form-item--small.el-form-item:last-child {
  483. margin: 0;
  484. }
  485. ::v-deep .el-radio-group {
  486. display: block;
  487. // line-height: 32px;
  488. .el-radio {
  489. line-height: 32px;
  490. }
  491. }
  492. }
  493. .upload_img {
  494. padding-left: 82px;
  495. }
  496. }
  497. }
  498. </style>
  499. <style>
  500. .avatar-uploader .el-upload {
  501. border: 1px dashed #d9d9d9;
  502. border-radius: 6px;
  503. cursor: pointer;
  504. position: relative;
  505. overflow: hidden;
  506. }
  507. .avatar-uploader .el-upload:hover {
  508. border-color: #409eff;
  509. }
  510. .avatar-uploader-icon {
  511. font-size: 28px;
  512. color: #8c939d;
  513. width: 178px;
  514. height: 178px;
  515. line-height: 178px;
  516. text-align: center;
  517. }
  518. .avatar {
  519. width: 178px;
  520. height: 178px;
  521. display: block;
  522. }
  523. </style>