index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <div class="main">
  3. <div class="search">
  4. <el-input placeholder="输入广告名称/编号" class="search-input" clearable v-model="mixins_query.name"></el-input>
  5. <el-select placeholder="状态" v-model="mixins_query.adStatus" clearable>
  6. <el-option v-for="(item, index) in advertisingStatus" :key="index" :label="item.label" :value="item.status">{{
  7. item.label
  8. }}</el-option>
  9. </el-select>
  10. <el-date-picker
  11. v-model="times"
  12. value-format="yyyyMMdd"
  13. type="daterange"
  14. range-separator="至"
  15. start-placeholder="开始日期"
  16. end-placeholder="结束日期"
  17. @change="effectiveDateToggle"
  18. ></el-date-picker>
  19. <el-button type="primary" placeholder="状态" class="search-btn" @click="mixins_search" icon="el-icon-search">查询 </el-button>
  20. <div class="search-icon">
  21. <el-tooltip class="item" effect="light" placement="bottom" content="新增">
  22. <i class="zoniot_font zoniot-icon-tianjia2" @click="addOrEdit('add')"></i>
  23. </el-tooltip>
  24. </div>
  25. </div>
  26. <div class="roles-wrap">
  27. <zz-table
  28. :cols="cols"
  29. :settings="{ showIndex: true, stripe: true }"
  30. :loading="mixins_onQuery"
  31. :data="mixins_list"
  32. :pageset="mixins_pageset"
  33. @page-change="pageChange"
  34. @selection-change="selectionChange"
  35. >
  36. <template slot-scope="scope" slot="opt">
  37. <div class="opt">
  38. <el-tooltip effect="light" placement="bottom" content="编辑">
  39. <i class="zoniot_font zoniot-icon-bianji" @click="addOrEdit('edit', scope.row)"></i>
  40. </el-tooltip>
  41. <el-tooltip effect="light" placement="bottom" content="删除">
  42. <i class="zoniot_font zoniot-icon-shanchu redText" @click="deluserbyidFn(scope.row.id)"></i>
  43. </el-tooltip>
  44. </div>
  45. </template>
  46. </zz-table>
  47. </div>
  48. </div>
  49. </template>
  50. <script>
  51. import list from '@utils/list.js';
  52. export default {
  53. mixins: [list],
  54. name: 'advertisingManagement',
  55. data() {
  56. return {
  57. // 数据列表
  58. advertisingStatus: [
  59. {
  60. status: 0,
  61. label: '未开始'
  62. },
  63. {
  64. status: 1,
  65. label: '播放中'
  66. },
  67. {
  68. status: 2,
  69. label: '已结束'
  70. },
  71. {
  72. status: 3,
  73. label: '已终止'
  74. }
  75. ],
  76. times: [],
  77. cols: [
  78. {
  79. label: '广告编号',
  80. prop: 'communityId'
  81. },
  82. {
  83. label: '广告名称',
  84. prop: 'name'
  85. },
  86. {
  87. label: '投放社区',
  88. prop: 'communityNames'
  89. },
  90. {
  91. label: '开始播放日期',
  92. prop: 'startTime'
  93. },
  94. {
  95. label: '结束播放日期',
  96. prop: 'endTime'
  97. },
  98. {
  99. label: '创建时间',
  100. prop: 'createDate'
  101. },
  102. {
  103. label: '状态',
  104. prop: 'adStatus',
  105. format(val) {
  106. if (val == 0) {
  107. return '未开始';
  108. } else if (val == 1) {
  109. return '播放中';
  110. } else if (val == 2) {
  111. return '已结束';
  112. } else if (val == 3) {
  113. return '已终止';
  114. }
  115. }
  116. },
  117. {
  118. label: '操作',
  119. prop: 'id',
  120. slot: 'opt',
  121. width: 150
  122. }
  123. ],
  124. mixins_post: 'get'
  125. };
  126. },
  127. created() {
  128. if (this.$store.getters['getAreaSelect'].length === 0) {
  129. this.getorgTree();
  130. }
  131. this.mixins_dataUrl = '/sc-community/advertising/page';
  132. this.mixins_query = {};
  133. this.mixins_search();
  134. },
  135. mounted() {},
  136. methods: {
  137. effectiveDateToggle(va) {
  138. let arr = va;
  139. if (!arr) {
  140. arr = ['', ''];
  141. }
  142. this.mixins_query.startDate = arr[0];
  143. this.mixins_query.endDate = arr[1];
  144. },
  145. getorgTree() {
  146. this.$http
  147. .get('/sc-community/assets/community/list')
  148. .then((data) => {
  149. this.$store.commit('setAreaSelect', data.data);
  150. })
  151. .catch(function () {});
  152. },
  153. deluserbyidFn(id) {
  154. let ids = [];
  155. if (!!id) {
  156. ids = [id];
  157. } else {
  158. if (!this.selectRow.length) {
  159. this.$message.error('您尚未选择要删除的记录,请选择后再操作批量删除');
  160. return;
  161. }
  162. this.selectRow.forEach((v) => {
  163. ids.push(v.id);
  164. });
  165. }
  166. const h = this.$createElement;
  167. this.$msgBox(`删除`, '删除后将无法恢复,请问是否继续?')
  168. .then(() => {
  169. this.$http.post('/sc-community/device/delete', ids).then(({ status, data, msg }) => {
  170. if (0 === status) {
  171. this.$message({
  172. type: 'success',
  173. message: '删除成功!'
  174. });
  175. this.mixins_search();
  176. }
  177. });
  178. })
  179. .catch(() => {});
  180. },
  181. Scrap(id) {
  182. this.$msgBox(`确认提示`, '设备报废后将无法正常接收数据,请问是否继续?')
  183. .then(() => {
  184. this.$http
  185. .post('/sc-community/device/deviceScrapInterface', { id: id, deviceStatus: 5 })
  186. .then(({ status, data, msg }) => {
  187. if (0 === status) {
  188. this.$message({
  189. type: 'success',
  190. message: '报废成功!'
  191. });
  192. this.mixins_search();
  193. }
  194. });
  195. })
  196. .catch(() => {});
  197. },
  198. addOrEdit(todo, data = {}) {
  199. new Promise((resolve) => {
  200. let title = '添加设备';
  201. if (todo !== 'add') {
  202. title = '修改设备';
  203. }
  204. this.$store.dispatch('addPopup', {
  205. url: '/deviceManagement/popups/addDeviceManagement.vue',
  206. width: '500px',
  207. height: '400px',
  208. props: {
  209. data,
  210. todo,
  211. productOptions: this.productOptions,
  212. callback: resolve
  213. },
  214. title: title
  215. });
  216. }).then(() => {
  217. this.mixins_search();
  218. });
  219. }
  220. }
  221. };
  222. </script>
  223. <style scoped lang='scss'>
  224. .QRImg > div {
  225. position: absolute;
  226. width: 100%;
  227. bottom: 0;
  228. text-align: center;
  229. left: 50%;
  230. transform: translateX(-50%);
  231. }
  232. </style>