problemInfo.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <div>
  3. <div class="search-term">
  4. <el-form :inline="true" :model="searchInfo" class="demo-form-inline">
  5. <el-form-item label="站点类型">
  6. <el-select v-model="searchInfo.siteType" clearable placeholder="请选择">
  7. <el-option v-for="item in this.siteType" :label="item.label" :value="item.value"/>
  8. </el-select>
  9. </el-form-item>
  10. <el-form-item label="处理状态">
  11. <el-select v-model="searchInfo.status" clearable placeholder="请选择">
  12. <el-option label="已处理" value="0"></el-option>
  13. <el-option label="未处理" value="1"></el-option>
  14. </el-select>
  15. </el-form-item>
  16. <el-form-item>
  17. <el-button size="mini" type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
  18. <el-button class="excel-btn" size="small" type="primary" icon="el-icon-download" @click="handleExcelExport()">导出</el-button>
  19. <el-popover v-model:visible="deleteVisible" placement="top" width="160">
  20. <p>确定要删除吗?</p>
  21. <div style="text-align: right; margin: 0">
  22. <el-button size="mini" type="text" @click="deleteVisible = false">取消</el-button>
  23. <el-button size="mini" type="primary" @click="onDelete">确定</el-button>
  24. </div>
  25. </el-popover>
  26. </el-form-item>
  27. </el-form>
  28. </div>
  29. <el-table
  30. ref="multipleTable"
  31. border
  32. stripe
  33. style="width: 100%"
  34. tooltip-effect="dark"
  35. :data="tableData"
  36. @selection-change="handleSelectionChange"
  37. >
  38. <el-table-column label="日期" width="180">
  39. <template #default="scope">{{ formatDate(scope.row.CreatedAt) }}</template>
  40. </el-table-column>
  41. <el-table-column label="发布人" prop="oper" width="120"/>
  42. <el-table-column label="站点" prop="siteName" width="220"/>
  43. <el-table-column label="站点类型" prop="siteType" width="120"/>
  44. <el-table-column label="处理状态" prop="status" width="120">
  45. <template #default="scope">
  46. <el-tag v-show="scope.row.status == 'Untreated'" type="warning">未处理</el-tag>
  47. <el-tag v-show="scope.row.status == 'Processed'" type="success">已处理</el-tag>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="责任部门" prop="department" width="120"/>
  51. <el-table-column label="操作">
  52. <template #default="scope">
  53. <el-button size="small" type="primary" class="table-button"
  54. @click="updateProblemInfo(scope.row)">查看详情
  55. </el-button>
  56. <el-button type="danger" icon="el-icon-delete" size="mini" @click="deleteRow(scope.row)">删除</el-button>
  57. </template>
  58. </el-table-column>
  59. </el-table>
  60. <el-pagination
  61. layout="total, sizes, prev, pager, next, jumper"
  62. :current-page="page"
  63. :page-size="pageSize"
  64. :page-sizes="[10, 30, 50, 100]"
  65. :style="{float:'right',padding:'20px'}"
  66. :total="total"
  67. @current-change="handleCurrentChange"
  68. @size-change="handleSizeChange"
  69. />
  70. <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" title="问题详情">
  71. <el-form :model="formData" label-position="right" label-width="80px">
  72. <el-card class="box-card">
  73. <el-descriptions title="基本信息" border :column="2">
  74. <el-descriptions-item label="发布人">{{ formData.oper }}</el-descriptions-item>
  75. <el-descriptions-item label="站点名称">{{ formData.siteName }}</el-descriptions-item>
  76. <el-descriptions-item label="站点位置">{{ formData.position }}</el-descriptions-item>
  77. <el-descriptions-item label="站点类型">{{ formData.siteType }}</el-descriptions-item>
  78. <el-descriptions-item label="处理状态">
  79. <el-tag v-show="formData.status == 'Untreated'" type="warning">未处理</el-tag>
  80. <el-tag v-show="formData.status == 'Processed'" type="success">已处理</el-tag>
  81. </el-descriptions-item>
  82. <el-descriptions-item label="责任部门">{{ formData.department }}</el-descriptions-item>
  83. </el-descriptions>
  84. </el-card>
  85. <el-card class="box-card">
  86. <el-descriptions title="问题列表" :column="1" direction="vertical">
  87. <el-descriptions-item v-for="item in formData.matter.split('|')">
  88. {{ this.matterList[item] != undefined ? this.matterList[item].label : '' }}
  89. </el-descriptions-item>
  90. </el-descriptions>
  91. </el-card>
  92. <el-card class="box-card">
  93. <el-descriptions title="问题图片/视频" direction="vertical">
  94. <el-descriptions-item label="问题图片(点击图片查看更多)">
  95. <el-image
  96. style="width: 260px; height: 240px"
  97. :src="(formData.imgList.length>0?formData.imgList[0]:'')"
  98. :preview-src-list="formData.imgList">
  99. </el-image>
  100. </el-descriptions-item>
  101. <el-descriptions-item label="问题视频">
  102. <span v-show="formData.video.length<1">无视频</span>
  103. <video style="object-fit:fill" controls width="400" height="240" v-show="formData.video.length>0" :src="formData.video">
  104. 您的浏览器不支持Video标签。
  105. </video>
  106. </el-descriptions-item>
  107. </el-descriptions>
  108. </el-card>
  109. <el-card class="box-card" v-show="formData.status=='Processed'">
  110. <el-descriptions title="处理结果" :column="1" border direction="vertical">
  111. <el-descriptions-item label="处理人">{{ formData.handler }}</el-descriptions-item>
  112. <el-descriptions-item label="处理内容">{{ formData.handText }}</el-descriptions-item>
  113. <el-descriptions-item label="处理图片(点击图片查看更多)">
  114. <el-image
  115. style="width: 260px; height: 240px"
  116. :src="(formData.handImgList.length>0?formData.handImgList[0]:'')"
  117. :preview-src-list="formData.handImgList">
  118. </el-image>
  119. </el-descriptions-item>
  120. </el-descriptions>
  121. </el-card>
  122. </el-form>
  123. </el-dialog>
  124. </div>
  125. </template>
  126. <script>
  127. import {
  128. createProblemInfo,
  129. deleteProblemInfo,
  130. deleteProblemInfoByIds,
  131. updateProblemInfo,
  132. findProblemInfo,
  133. getProblemInfoList,
  134. exportExcel
  135. } from '@/api/problemInfo' // 此处请自行替换地址
  136. import infoList from '@/mixins/infoList'
  137. import { getDict } from '@/utils/dictionary'
  138. export default {
  139. name: 'ProblemInfo',
  140. mixins: [infoList],
  141. data() {
  142. return {
  143. listApi: getProblemInfoList,
  144. dialogFormVisible: false,
  145. type: '',
  146. siteType: [],
  147. deleteVisible: false,
  148. multipleSelection: [],
  149. matterList: [],
  150. formData: {
  151. oper: 0,
  152. handler: 0,
  153. imgs: '',
  154. imgList: [],
  155. handImgList: [],
  156. video: '',
  157. siteId: 0,
  158. position: '',
  159. matter: '',
  160. siteType: '',
  161. status: '',
  162. handImgs: '',
  163. handText: '',
  164. department: '',
  165. }
  166. }
  167. },
  168. async created() {
  169. this.siteType = await getDict('site_type')
  170. await this.getTableData()
  171. },
  172. methods: {
  173. handleExcelExport() {
  174. exportExcel(this.formData)
  175. },
  176. // 条件搜索前端看此方法
  177. onSubmit() {
  178. this.page = 1
  179. this.pageSize = 10
  180. this.getTableData()
  181. },
  182. handleSelectionChange(val) {
  183. this.multipleSelection = val
  184. },
  185. deleteRow(row) {
  186. this.$confirm('确定要删除吗?', '提示', {
  187. confirmButtonText: '确定',
  188. cancelButtonText: '取消',
  189. type: 'warning'
  190. }).then(() => {
  191. this.deleteProblemInfo(row)
  192. })
  193. },
  194. async onDelete() {
  195. const ids = []
  196. if (this.multipleSelection.length === 0) {
  197. this.$message({
  198. type: 'warning',
  199. message: '请选择要删除的数据'
  200. })
  201. return
  202. }
  203. this.multipleSelection &&
  204. this.multipleSelection.map(item => {
  205. ids.push(item.ID)
  206. })
  207. const res = await deleteProblemInfoByIds({ids})
  208. if (res.code === 0) {
  209. this.$message({
  210. type: 'success',
  211. message: '删除成功'
  212. })
  213. if (this.tableData.length === ids.length && this.page > 1) {
  214. this.page--
  215. }
  216. this.deleteVisible = false
  217. this.getTableData()
  218. }
  219. },
  220. async updateProblemInfo(row) {
  221. const res = await findProblemInfo({ID: row.ID})
  222. this.type = 'update'
  223. if (res.code === 0) {
  224. this.formData = res.data.reproblemInfo
  225. if (this.formData.imgs.length > 0) {
  226. this.formData.imgList = this.formData.imgs.split('|')
  227. } else {
  228. this.formData.imgList = []
  229. }
  230. if (this.formData.handImgs.length > 0) {
  231. this.formData.handImgList = this.formData.handImgs.split('|')
  232. } else {
  233. this.formData.handImgList = []
  234. }
  235. this.matterList = await getDict('site_' + this.formData.siteId)
  236. this.dialogFormVisible = true
  237. }
  238. },
  239. closeDialog() {
  240. const video = document.getElementById('video')
  241. if (video != undefined) {
  242. video.pause()
  243. }
  244. this.dialogFormVisible = false
  245. this.formData = {
  246. oper: 0,
  247. handler: 0,
  248. imgs: '',
  249. video: '',
  250. siteId: 0,
  251. imgList: [],
  252. position: '',
  253. matter: '',
  254. handImgList: [],
  255. siteType: '',
  256. status: '',
  257. handImgs: '',
  258. handText: '',
  259. department: '',
  260. }
  261. },
  262. async deleteProblemInfo(row) {
  263. const res = await deleteProblemInfo({ID: row.ID})
  264. if (res.code === 0) {
  265. this.$message({
  266. type: 'success',
  267. message: '删除成功'
  268. })
  269. if (this.tableData.length === 1 && this.page > 1) {
  270. this.page--
  271. }
  272. this.getTableData()
  273. }
  274. },
  275. async enterDialog() {
  276. let res
  277. switch (this.type) {
  278. case 'create':
  279. res = await createProblemInfo(this.formData)
  280. break
  281. case 'update':
  282. res = await updateProblemInfo(this.formData)
  283. break
  284. default:
  285. res = await createProblemInfo(this.formData)
  286. break
  287. }
  288. if (res.code === 0) {
  289. this.$message({
  290. type: 'success',
  291. message: '创建/更改成功'
  292. })
  293. this.closeDialog()
  294. this.getTableData()
  295. }
  296. },
  297. openDialog() {
  298. this.type = 'create'
  299. this.dialogFormVisible = true
  300. }
  301. },
  302. }
  303. </script>
  304. <style>
  305. .box-card {
  306. margin-bottom: 10px;
  307. }
  308. </style>