index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <div class="app-container">
  3. <!-- 筛选start -->
  4. <div class="filter-container mb-10">
  5. <div class="left">
  6. <div>
  7. <a class="" style="margin-right: 30px">计划停电列表</a>
  8. <el-button icon="el-icon-plus" type="success" @click="addItem()" :disabled="store.state.authorities.indexOf('新增')==-1">
  9. 新增
  10. </el-button>
  11. </div>
  12. <div style="margin-top: 20px">
  13. <div class="filter-item planOutage">
  14. 选择时间范围:
  15. <el-date-picker
  16. v-model="dateTime"
  17. type="datetimerange"
  18. range-separator="至"
  19. start-placeholder="开始日期"
  20. end-placeholder="结束日期"
  21. style="width: auto"
  22. :disabled="store.state.authorities.indexOf('查询')==-1"
  23. ></el-date-picker>
  24. </div>
  25. <div class="filter-item">
  26. 状态:
  27. <el-select
  28. v-model="region"
  29. placeholder="请选择"
  30. style="width: 200px"
  31. clearable
  32. :disabled="store.state.authorities.indexOf('查询')==-1"
  33. >
  34. <el-option label="未执行" :value="1"></el-option>
  35. <el-option label="执行中" :value="2"></el-option>
  36. <el-option label="已执行" :value="3"></el-option>
  37. </el-select>
  38. </div>
  39. <el-button
  40. type="primary"
  41. icon="el-icon-search"
  42. @click="Select()"
  43. class="search-button"
  44. :disabled="store.state.authorities.indexOf('查询')==-1"
  45. >
  46. 搜索
  47. </el-button>
  48. </div>
  49. </div>
  50. <div class="right">
  51. <el-button type="primary" @click="DataReportExport()" :disabled="store.state.authorities.indexOf('导出')==-1">导出</el-button>
  52. </div>
  53. </div>
  54. <!-- 筛选end -->
  55. <!-- 表格start -->
  56. <el-table
  57. :data="tableData"
  58. border
  59. stripe
  60. :header-cell-style="headClass"
  61. :cell-style="cellStyle"
  62. >
  63. <el-table-column type="index" label="序号" width="50px"></el-table-column>
  64. <el-table-column
  65. prop="siteName"
  66. label="站点名称"
  67. min-width="160px"
  68. ></el-table-column>
  69. <el-table-column
  70. prop="startTime"
  71. label="开始停电时间"
  72. min-width="155px"
  73. ></el-table-column>
  74. <el-table-column
  75. prop="endTime"
  76. label="结束停电时间"
  77. min-width="155px"
  78. ></el-table-column>
  79. <el-table-column
  80. prop="createTime"
  81. label="提交时间"
  82. min-width="155px"
  83. ></el-table-column>
  84. <el-table-column prop="creator" label="提交人" min-width="110px"></el-table-column>
  85. <el-table-column prop="contacts" label="联系人" min-width="110px"></el-table-column>
  86. <el-table-column prop="phone" label="联系方式" min-width="110px"></el-table-column>
  87. <el-table-column prop="type" label="状态" width="">
  88. <template #default="scope">
  89. <span
  90. :style="{
  91. color:
  92. scope.row.type == 3
  93. ? '#8DCF6E'
  94. : scope.row.type === 1
  95. ? '#FF747B'
  96. : '#5c88fa',
  97. }"
  98. >
  99. {{
  100. scope.row.type === 1
  101. ? '未执行'
  102. : scope.row.type === 2
  103. ? '执行中'
  104. : '已执行'
  105. }}
  106. </span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column fixed="right" label="操作" width="180">
  110. <template #default="scope">
  111. <el-button
  112. type="text"
  113. size="small"
  114. @click.prevent="editRow(scope.row)"
  115. :disabled="store.state.authorities.indexOf('修改')==-1"
  116. >
  117. 编辑
  118. </el-button>
  119. <el-popconfirm
  120. confirm-button-text="是"
  121. cancel-button-text="否"
  122. icon="el-icon-info"
  123. icon-color="red"
  124. title="确定删除?"
  125. @confirm="handleDelete(scope.row)"
  126. @cancel="cancelEvent"
  127. >
  128. <template #reference>
  129. <el-button type="text" size="small" class="delete-text" :disabled="store.state.authorities.indexOf('删除')==-1">
  130. 删除
  131. </el-button>
  132. </template>
  133. </el-popconfirm>
  134. </template>
  135. </el-table-column>
  136. </el-table>
  137. <!-- 表格end -->
  138. <!-- 分页start -->
  139. <div class="paginationBlock">
  140. <el-pagination
  141. v-model:currentPage="currentPage"
  142. :page-sizes="[15, 20, 25, 30]"
  143. :page-size="pageSize"
  144. layout="total, sizes, prev, pager, next, jumper"
  145. :total="total"
  146. @size-change="handleSizeChange"
  147. @current-change="handleCurrentChange"
  148. background
  149. ></el-pagination>
  150. </div>
  151. <!-- 分页end -->
  152. <!--弹框组件开始-----------------------start-->
  153. <dialog-component
  154. :dialog-title="dialogTitle"
  155. :item-info="tableItem"
  156. @closeDialog="closeDialog"
  157. :show_Dialog="showDialog"
  158. ></dialog-component>
  159. <!--弹框组件开始-----------------------end-->
  160. </div>
  161. </template>
  162. <script>
  163. import { useStore } from 'vuex'
  164. import { defineComponent, onMounted, ref } from 'vue'
  165. import DialogComponent from './dialogComponent'
  166. import * as api from '@/api/planOutage/index'
  167. import { ElMessage } from 'element-plus'
  168. export default defineComponent({
  169. name: 'VariableList',
  170. components: { DialogComponent },
  171. setup() {
  172. const store = useStore()
  173. const tableItem = ref()
  174. const dialogTitle = ref('')
  175. const showDialog = ref(false)
  176. const tableData = ref()
  177. const currentPage = ref(1)
  178. const pageSize = ref(15)
  179. const total = ref(0)
  180. // const dateTime = ref([
  181. // new Date(2021, 8, 10, 10, 10),
  182. // new Date(2021, 10, 11, 10, 10),
  183. // ])
  184. const dateTime = ref('')
  185. const select = ref(1)
  186. const tabPosition = ref('one')
  187. const input = ref('')
  188. const region = ref()
  189. // 添加操作
  190. const addItem = () => {
  191. tableItem.value = {
  192. siteId: '',
  193. time: ['', ''],
  194. startTime: '',
  195. endTime: '',
  196. phone: '',
  197. contacts: '',
  198. planType: '',
  199. type: '',
  200. }
  201. dialogTitle.value = '新增'
  202. showDialog.value = true
  203. }
  204. // 编辑操作
  205. const editRow = (row) => {
  206. console.log(row)
  207. tableItem.value = {
  208. id: row.id,
  209. siteId: row.siteId,
  210. time: [row.startTime, row.endTime],
  211. startTime: row.startTime,
  212. endTime: row.endTime,
  213. phone: row.phone,
  214. contacts: row.contacts,
  215. planType: row.planType,
  216. type: row.type,
  217. }
  218. dialogTitle.value = '编辑'
  219. showDialog.value = true
  220. }
  221. // 关闭操作
  222. const closeDialog = (flag) => {
  223. if (flag) {
  224. // 重新刷新表格内容
  225. this.fetchData()
  226. }
  227. showDialog.value = false
  228. Select()
  229. }
  230. //删除 是否删除 ---- 是
  231. const handleDelete = (row) => {
  232. api.plannedOutageDel({ id: row.id }).then((requset) => {
  233. if (requset.status === 'SUCCESS') {
  234. ElMessage.success({
  235. message: '删除成功',
  236. type: 'success',
  237. })
  238. Select()
  239. } else {
  240. ElMessage.error(requset.msg)
  241. }
  242. })
  243. }
  244. //是否删除 ---- 否
  245. const cancelEvent = () => {
  246. console.log('cancel!')
  247. }
  248. //查询设备列表
  249. function Select() {
  250. store.commit('TimeAll_function', dateTime.value)
  251. const time = store.state.Time_Data
  252. api
  253. .plannedOutageList({
  254. size: pageSize.value,
  255. current: currentPage.value,
  256. type: region.value,
  257. startTime: time[0]?time[0]:'',
  258. endTime: time[1]?time[1]:'',
  259. })
  260. .then((requset) => {
  261. if (requset.status === 'SUCCESS') {
  262. tableData.value = requset.data.records.map((val) => {
  263. store.commit('getTimestampAll', val.startTime)
  264. val.startTime = store.state.timeProcessing
  265. store.commit('getTimestampAll', val.endTime)
  266. val.endTime = store.state.timeProcessing
  267. store.commit('getTimestampAll', val.createTime)
  268. val.createTime = store.state.timeProcessing
  269. })
  270. tableData.value = requset.data.records
  271. total.value = requset.data.total
  272. } else {
  273. ElMessage.error(requset.msg)
  274. }
  275. })
  276. }
  277. onMounted(() => {
  278. Select()
  279. })
  280. const handleSizeChange = (val) => {
  281. pageSize.value = val
  282. Select()
  283. }
  284. const handleCurrentChange = (val) => {
  285. currentPage.value = val
  286. Select()
  287. }
  288. // 表头样式设置
  289. const goVariableList = () => {
  290. // 跳转至订单列表页面传参
  291. this.$router.push({
  292. path: '../siteManage/variableList/index.vue',
  293. })
  294. // this.$router.push({ name:'variableList'})
  295. }
  296. const headClass = () => {
  297. return 'background:#FAFAFA;'
  298. }
  299. //处理状态状态值变色
  300. const cellStyle = ({ row, column, rowIndex, columnIndex }) => {
  301. row, column, rowIndex
  302. // console.log(row, column, rowIndex)
  303. if (columnIndex) {
  304. // return `text-align:left;cursor:pointer;`
  305. } else {
  306. return ''
  307. }
  308. }
  309. //导出
  310. const DataReportExport = () => {
  311. store.commit('TimeAll_function', dateTime.value)
  312. const time = store.state.Time_Data
  313. api
  314. .outagePlanListExport({
  315. type: region.value,
  316. startTime: time[0]?time[0]:'',
  317. endTime: time[1]?time[1]:'',
  318. })
  319. .then((requset) => {
  320. if (requset.status === 'SUCCESS') {
  321. window.location.href = process.env.VUE_APP_FILE_URL + requset.data
  322. ElMessage.success({
  323. message: '导出成功',
  324. type: 'success',
  325. })
  326. } else {
  327. ElMessage.error(requset.msg)
  328. }
  329. })
  330. }
  331. return {
  332. cellStyle,
  333. headClass,
  334. goVariableList,
  335. handleDelete,
  336. cancelEvent,
  337. closeDialog,
  338. editRow,
  339. addItem,
  340. Select,
  341. store,
  342. total,
  343. pageSize,
  344. currentPage,
  345. handleSizeChange,
  346. handleCurrentChange,
  347. tableData,
  348. showDialog,
  349. tabPosition,
  350. select,
  351. dateTime,
  352. tableItem,
  353. dialogTitle,
  354. input,
  355. region,
  356. DataReportExport
  357. }
  358. },
  359. })
  360. </script>
  361. <style lang="scss" scoped>
  362. </style>