多媒体信息发布平台
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.

414 lines
12 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
  1. <template>
  2. <div class="list_warp">
  3. <el-row :gutter="15">
  4. <el-col>
  5. <el-table
  6. ref="table"
  7. v-loading="crud.loading"
  8. :data="tableData"
  9. :header-cell-style="{ background: '#3a8aeb', color: '#fff' }"
  10. class="publish_table"
  11. @selection-change="handleSelectionChange"
  12. >
  13. <el-table-column type="selection" width="55" />
  14. <el-table-column label="文件名称" align="center" prop="name" />
  15. <el-table-column label="发布内容" align="center" prop="content">
  16. <template slot-scope="scope">
  17. <div>
  18. <img width="100px" size="medium" :src="scope.row.cover" />
  19. </div>
  20. </template>
  21. </el-table-column>
  22. <el-table-column label="发布时间" align="center" prop="date" />
  23. <el-table-column label="发布类型" align="center" prop="type">
  24. <template slot-scope="scope">
  25. <div>{{ scope.row.type ? '定时发布' : '即时发布' }}</div>
  26. </template>
  27. </el-table-column>
  28. <el-table-column label="发布人" align="center" prop="user" />
  29. <el-table-column label="状态" align="center" prop="enabled">
  30. <template slot-scope="scope">
  31. <div :class="{ 'stop_txt': scope.row.enabled }">{{ scope.row.enabled ? '发布中' : '停止' }}</div>
  32. </template>
  33. </el-table-column>
  34. <el-table-column prop="device" align="center" label="发布设备" width="300px">
  35. <template slot-scope="scope">
  36. <div>
  37. {{ scope.row.device ? '' : '全部设备' }}
  38. <div class="tag_list">
  39. <el-tag
  40. v-for="tag in scope.row.deviceData"
  41. :key="tag"
  42. type="primary"
  43. >{{ tag }}</el-tag>
  44. </div>
  45. </div>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="操作" width="220px" align="center" fixed="right">
  49. <template slot-scope="scope">
  50. <el-button
  51. type="primary"
  52. :class="['top_btn', { 'top_btn_active': scope.row.isTop }]"
  53. @click="isTophandle(scope.$index, scope.row)"
  54. >{{ scope.row.isTop ? '取消' : '置顶' }}</el-button>
  55. <el-button
  56. type="primary"
  57. class="edit_btn"
  58. @click="editForm(scope.$index, scope.row)"
  59. >编辑</el-button>
  60. <el-button
  61. type="primary"
  62. :class="['start_btn', { 'stop_btn': scope.row.enabled }]"
  63. @click="isStopHandle(scope.$index, scope.row)"
  64. >{{ scope.row.enabled ? '停止' : '恢复' }}</el-button>
  65. <el-button type="info" class="delt_btn">删除</el-button>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <!--分页组件-->
  70. <pagination />
  71. </el-col>
  72. </el-row>
  73. <div class="publish_layer">
  74. <el-dialog
  75. title="编辑"
  76. :close-on-click-modal="false"
  77. :visible.sync="publishVisible"
  78. width="872px"
  79. height="384px"
  80. >
  81. <el-form ref="form" :model="form" size="small" label-width="100px">
  82. <el-form-item
  83. label="发布名称"
  84. prop="name"
  85. :rules="[
  86. { required: true, message: '请输入发布名称', trigger: '' }
  87. ]"
  88. >
  89. <el-input v-model="form.name" style="width: 674px;" />
  90. </el-form-item>
  91. <el-form-item
  92. label="发布时间"
  93. prop="date"
  94. :rules="[
  95. { required: true, message: '请选择发布时间', trigger: 'change' }
  96. ]"
  97. >
  98. <el-date-picker
  99. v-if="isTypeDate===0"
  100. v-model="form.date"
  101. type="date"
  102. placeholder="选择日期"
  103. />
  104. <el-date-picker
  105. v-else
  106. v-model="form.date"
  107. type="daterange"
  108. range-separator="至"
  109. start-placeholder="开始日期"
  110. end-placeholder="结束日期"
  111. />
  112. </el-form-item>
  113. <el-form-item label="上传内容" prop="file">
  114. <el-upload action="#" list-type="picture-card" :auto-upload="false">
  115. <!-- <i slot="default" class="el-icon-plus"></i> -->
  116. <img src="@/assets/images/t-sc.png" alt />
  117. <div slot="file" slot-scope="{file}">
  118. <img class="el-upload-list__item-thumbnail" :src="file.url" alt />
  119. <!-- <span class="el-upload-list__item-actions">
  120. <span
  121. class="el-upload-list__item-preview"
  122. @click="handlePictureCardPreview(file)"
  123. >
  124. <i class="el-icon-zoom-in"></i>
  125. </span>
  126. <span
  127. v-if="!disabled"
  128. class="el-upload-list__item-delete"
  129. @click="handleDownload(file)"
  130. >
  131. <i class="el-icon-download"></i>
  132. </span>
  133. <span
  134. v-if="!disabled"
  135. class="el-upload-list__item-delete"
  136. @click="handleRemove(file)"
  137. >
  138. <i class="el-icon-delete"></i>
  139. </span>
  140. </span>-->
  141. </div>
  142. </el-upload>
  143. <!-- <el-dialog :visible.sync="dialogVisible">
  144. <img width="100%" :src="dialogImageUrl" alt />
  145. </el-dialog>-->
  146. </el-form-item>
  147. <el-form-item
  148. label="选择设备"
  149. prop="deviceSelect"
  150. :rules="[
  151. { required: true, message: '请选择设备', trigger: 'change' },
  152. ]"
  153. >
  154. <el-radio-group v-model="form.deviceSelect">
  155. <el-radio label="all" value="all">所有设备</el-radio>
  156. <el-radio label="other" value="other">部分设备<i v-if="form.deviceSelect === 'other'" class="radio_tip" @click="addDeviceTag()">添加</i></el-radio>
  157. </el-radio-group>
  158. </el-form-item>
  159. <div v-if="form.deviceSelect === 'all'" class="select_all_tip">所有设备都将被发送</div>
  160. <div v-if="deviceTags.length > 0 && form.deviceSelect === 'other'" class="select_other">
  161. <el-row>
  162. <el-col :span="10" class="other_tip">以下设备都将被发送<span>总计{{ deviceTags.length }}个设备</span></el-col>
  163. <el-col :span="4">
  164. <el-button round class="delt_btn" @click="clearDevice()">清空</el-button>
  165. </el-col>
  166. </el-row>
  167. <el-tag
  168. v-for="tag in deviceTags"
  169. :key="tag"
  170. closable
  171. :disable-transitions="true"
  172. :hit="false"
  173. color="#cbe3ff"
  174. @close="handleClose(tag)"
  175. >
  176. {{ tag }}
  177. </el-tag>
  178. </div>
  179. </el-form>
  180. <div slot="footer" class="dialog-footer">
  181. <el-button :loading="crud.status.cu === 2" type="primary" round @click="crud.submitCU">保存</el-button>
  182. <el-button round @click="crud.cancelCU">关闭</el-button>
  183. </div>
  184. </el-dialog>
  185. </div>
  186. <!-- 添加发布的设备 -->
  187. <div class="add_device_layer">
  188. <el-dialog
  189. title="请选择设备"
  190. :close-on-click-modal="false"
  191. :visible.sync="selectDeviceVisible"
  192. width="400px"
  193. >
  194. <el-tag
  195. v-for="tag in deviceAllTags"
  196. :key="tag"
  197. :disable-transitions="true"
  198. :hit="false"
  199. color="#cbe3ff"
  200. class="all_tags"
  201. @click="tagHandle(tag)"
  202. >
  203. {{ tag }}
  204. </el-tag>
  205. </el-dialog>
  206. </div>
  207. </div>
  208. </template>
  209. <script>
  210. import crudDept from '@/api/system/dept'
  211. import CRUD, { presenter, header, form, crud } from '@crud/crud'
  212. import pagination from '@crud/Pagination'
  213. const defaultForm = {
  214. name: '',
  215. date: null,
  216. deviceSelect: '',
  217. file: ''
  218. }
  219. export default {
  220. name: 'PublishList',
  221. components: { pagination },
  222. cruds() {
  223. return CRUD({ title: '部门', url: 'api/dept', crudMethod: { ...crudDept }})
  224. },
  225. mixins: [presenter(), header(), form(defaultForm), crud()],
  226. data() {
  227. return {
  228. selectedList: [],
  229. publishVisible: false,
  230. messageVisible: false,
  231. selectDeviceVisible: false,
  232. isTypeDate: 0,
  233. tableData: [
  234. {
  235. id: 1,
  236. name: '及时发布 2022-1-1',
  237. cover: require('@/assets/images/background.jpg'),
  238. type: 0,
  239. user: '某某某',
  240. device: 0,
  241. deviceData: [],
  242. enabled: true,
  243. isTop: true,
  244. date: '2021-2-2'
  245. },
  246. {
  247. id: 2,
  248. name: '定时发布 2022-1-1',
  249. cover: require('@/assets/images/background.jpg'),
  250. type: 1,
  251. user: '某某某2',
  252. device: 1,
  253. deviceData: ['GCXR1', 'GCXR2', 'GCXR3', 'GCXR4', 'GCXR5'],
  254. enabled: false,
  255. isTop: false,
  256. date: '2021-2-2 至 2022-4-6'
  257. }
  258. ],
  259. deviceAllTags: ['GCXR1', 'GCXR2', 'GCXR3', 'GCXR4', 'GCXR5'],
  260. deviceTags: []
  261. }
  262. },
  263. methods: {
  264. isTophandle(index, row) {
  265. row.isTop = !row.isTop
  266. },
  267. isStopHandle(index, row) {
  268. row.enabled = !row.enabled
  269. },
  270. editForm(index, row) {
  271. this.publishVisible = true
  272. this.form.name = row.name
  273. this.isTypeDate = row.type
  274. if (this.isTypeDate === 0) {
  275. this.form.date = row.date
  276. } else {
  277. const dateSplice = row.date.split('至')
  278. this.form.date = dateSplice
  279. }
  280. if (row.device === 0) {
  281. this.form.deviceSelect = 'all'
  282. } else {
  283. this.form.deviceSelect = 'other'
  284. }
  285. this.deviceTags = row.deviceData
  286. },
  287. handleSelectionChange(val) {
  288. this.selectedList = val
  289. if (val.length > 0) {
  290. this.clearBtnDisabled = false
  291. } else {
  292. this.clearBtnDisabled = true
  293. }
  294. console.log(val)
  295. },
  296. addDeviceTag() {
  297. this.selectDeviceVisible = true
  298. },
  299. tagHandle(tag) {
  300. console.log(tag)
  301. this.deviceTags.push(tag)
  302. },
  303. handleClose(tag) {
  304. this.deviceTags.splice(this.deviceTags.indexOf(tag), 1)
  305. console.log(this.deviceTags)
  306. },
  307. clearDevice() {
  308. this.deviceTags = []
  309. }
  310. }
  311. }
  312. </script>
  313. <style lang="scss" scoped>
  314. .list_warp {
  315. padding: 0 24px;
  316. .stop_txt {
  317. color: #3a8aeb;
  318. }
  319. }
  320. ::v-deep .el-range-separator{
  321. width: 24px;
  322. }
  323. ::v-deep .el-radio-group{
  324. display: block;
  325. .el-radio{
  326. position: relative;
  327. line-height: 40px;
  328. .radio_tip{
  329. position: absolute;
  330. right: -45px;
  331. top: 0;
  332. display: block;
  333. width: 42px;
  334. height: 21px;
  335. line-height: 21px;
  336. font-size: 12px;
  337. text-align: center;
  338. color: #fff;
  339. background: url(~@/assets/images/an-tj.png) no-repeat;
  340. background-size: 42px 21px;
  341. }
  342. }
  343. }
  344. .select_all_tip{
  345. width: 336px;
  346. height: 32px;
  347. line-height: 32px;
  348. margin: -20px 0 0 100px;
  349. padding: 0 14px;
  350. font-size: 12px;
  351. color: #999;
  352. background: #fff;
  353. box-shadow: 0 0 5px rgba(0,0,0,.14);
  354. }
  355. .select_other{
  356. width: 600px;
  357. margin: -20px 0 0 100px;
  358. padding: 18px 23px;
  359. background: #f8f8f8;
  360. border: 1px solid #dcdde3;
  361. border-radius: 4px;
  362. .other_tip{
  363. line-height: 24px;
  364. span{
  365. display: inline-block;
  366. margin-left: 20px;
  367. }
  368. }
  369. .el-button {
  370. padding: 5px 8px;
  371. border: none !important;
  372. }
  373. .delt_btn {
  374. color: #fff;
  375. background-color: #ee5747 !important;
  376. }
  377. }
  378. .publish_layer,
  379. .add_device_layer{
  380. .el-tag--small{
  381. height: 28px;
  382. line-height: 26px;
  383. padding: 0 24px;
  384. margin: 18px 16px 0 0;
  385. font-size: 14px;
  386. // color: #3a8aeb;
  387. ::v-deep .el-icon-close{
  388. font-size: 16px;
  389. }
  390. }
  391. }
  392. .add_device_layer{
  393. ::v-deep .el-dialog__body{
  394. padding: 0 20px 30px 20px;
  395. }
  396. }
  397. .publish_table{
  398. .tag_list{
  399. text-align: left;
  400. .el-tag {
  401. height: 26px;
  402. line-height: 26px;
  403. margin: 5px 10px 5px 0;
  404. background: #cbe3ff;
  405. color: #3a8aeb;
  406. border: none;
  407. }
  408. }
  409. }
  410. </style>