index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
  4. <el-form-item label="问题描述" prop="description">
  5. <el-input
  6. v-model="queryParams.description"
  7. placeholder="请输入问题描述"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item prop="createTime">
  13. <el-date-picker
  14. v-model="queryParams.createTime"
  15. value-format="yyyy-MM-dd"
  16. type="date"
  17. placeholder="选择日期">
  18. </el-date-picker>
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  22. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <el-row :gutter="10" class="mb8">
  26. <el-col :span="1.5">
  27. <el-button
  28. type="danger"
  29. icon="el-icon-delete"
  30. size="mini"
  31. :disabled="multiple"
  32. @click="handleDelete"
  33. >删除</el-button>
  34. </el-col>
  35. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  36. </el-row>
  37. <el-table v-loading="loading" :data="issueList" @selection-change="handleSelectionChange">
  38. <el-table-column type="selection" width="55" align="center" />
  39. <el-table-column label="序号" width="50">
  40. <template slot-scope="scope">
  41. {{(scope.$index + 1) + ((queryParams.pageNum - 1) * queryParams.pageSize)}}
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="问题名称" align="center" prop="title" />
  45. <el-table-column label="问题描述" align="center" prop="description" />
  46. <el-table-column label="上报人" align="center" prop="person" />
  47. <el-table-column label="问题状态" align="center">
  48. <template slot-scope="scope">
  49. <span v-if="scope.row.status == 1" style="color: #42b983">●已解决</span>
  50. <span v-if="scope.row.status == 0" style="color: #C03639">●待解决</span>
  51. </template>
  52. </el-table-column>
  53. <el-table-column label="创建时间" align="center" prop="createTime" />
  54. <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
  55. <template slot-scope="scope">
  56. <el-button
  57. size="mini"
  58. type="text"
  59. icon="el-icon-edit"
  60. @click="handleUpdate(scope.row)"
  61. >查看</el-button>
  62. <el-button
  63. size="mini"
  64. type="text"
  65. icon="el-icon-delete"
  66. @click="handleDelete(scope.row)"
  67. >删除</el-button>
  68. </template>
  69. </el-table-column>
  70. </el-table>
  71. <pagination
  72. v-show="total>0"
  73. :total="total"
  74. :page.sync="queryParams.pageNum"
  75. :limit.sync="queryParams.pageSize"
  76. @pagination="getList"
  77. />
  78. <!-- 添加或修改上报问题对话框 -->
  79. <el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="800px" append-to-body>
  80. <el-form ref="form" :model="form" label-width="80px">
  81. <el-form-item label="所属项目" prop="projectId">
  82. <el-input v-model="form.projectName" readonly/>
  83. </el-form-item>
  84. <el-form-item label="问题名称" prop="title">
  85. <el-input v-model="form.title" readonly/>
  86. </el-form-item>
  87. <el-form-item label="上报人" prop="person">
  88. <el-input v-model="form.person" readonly/>
  89. </el-form-item>
  90. <el-form-item label="问题描述" prop="description">
  91. <el-input type="textarea" v-model="form.description" readonly/>
  92. </el-form-item>
  93. <el-form-item label="整改要求" prop="need">
  94. <el-input type="textarea" v-model="form.need" readonly/>
  95. </el-form-item>
  96. </el-form>
  97. <div slot="footer" class="dialog-footer">
  98. <!-- <el-button type="primary" @click="submitForm">确 定</el-button>-->
  99. <!-- <el-button @click="cancel">取 消</el-button>-->
  100. </div>
  101. </el-dialog>
  102. </div>
  103. </template>
  104. <script>
  105. import { listIssue, getIssue, delIssue, addIssue, updateIssue } from "@/api/zcustom/issue";
  106. import { listProject } from '@/api/zcustom/project'
  107. export default {
  108. name: "Issue",
  109. data() {
  110. return {
  111. // 根路径
  112. baseURL: process.env.VUE_APP_BASE_API,
  113. // 遮罩层
  114. loading: true,
  115. // 选中数组
  116. ids: [],
  117. // 非单个禁用
  118. single: true,
  119. // 非多个禁用
  120. multiple: true,
  121. // 显示搜索条件
  122. showSearch: true,
  123. // 总条数
  124. total: 0,
  125. // 上报问题表格数据
  126. issueList: [],
  127. projectList: [],
  128. // 弹出层标题
  129. title: "",
  130. // 是否显示弹出层
  131. open: false,
  132. // 查询参数
  133. queryParams: {
  134. pageNum: 1,
  135. pageSize: 10,
  136. description: null,
  137. projectId: null,
  138. status: null,
  139. createTime: null
  140. },
  141. // 表单参数
  142. form: {},
  143. // 表单校验
  144. rules: {
  145. description: [
  146. { required: true, message: "问题描述不能为空", trigger: "blur" }
  147. ],
  148. need: [
  149. { required: true, message: "整改要求不能为空", trigger: "blur" }
  150. ],
  151. title: [
  152. { required: true, message: "问题名称不能为空", trigger: "blur" }
  153. ],
  154. projectId: [
  155. { required: true, message: "所属项目不能为空", trigger: "blur" }
  156. ],
  157. }
  158. };
  159. },
  160. created() {
  161. this.getList();
  162. this.getPrjList()
  163. },
  164. methods: {
  165. /** 查询上报问题列表 */
  166. getList() {
  167. this.loading = true;
  168. listIssue(this.queryParams).then(response => {
  169. console.log(response)
  170. this.issueList = response.data;
  171. this.total = response.data.length;
  172. this.loading = false;
  173. });
  174. },
  175. getPrjList() {
  176. listProject().then(response => {
  177. this.projectList = response.data.records;
  178. });
  179. },
  180. // 取消按钮
  181. cancel() {
  182. this.open = false;
  183. this.reset();
  184. },
  185. // 表单重置
  186. reset() {
  187. this.form = {
  188. id: null,
  189. description: null,
  190. projectId: null,
  191. projectName: null,
  192. status: "0",
  193. delFlag: null,
  194. };
  195. this.resetForm("form");
  196. },
  197. /** 搜索按钮操作 */
  198. handleQuery() {
  199. this.queryParams.pageNum = 1;
  200. this.getList();
  201. },
  202. /** 重置按钮操作 */
  203. resetQuery() {
  204. this.resetForm("queryForm");
  205. this.handleQuery();
  206. },
  207. // 多选框选中数据
  208. handleSelectionChange(selection) {
  209. this.ids = selection.map(item => item.id)
  210. this.single = selection.length!==1
  211. this.multiple = !selection.length
  212. },
  213. /** 新增按钮操作 */
  214. handleAdd() {
  215. this.reset();
  216. this.open = true;
  217. this.title = "添加上报问题";
  218. },
  219. /** 修改按钮操作 */
  220. handleUpdate(row) {
  221. this.reset();
  222. const id = row.id || this.ids
  223. getIssue(id).then(response => {
  224. this.form = response.data;
  225. this.open = true;
  226. this.title = "问题详情";
  227. });
  228. },
  229. /** 提交按钮 */
  230. submitForm() {
  231. this.$refs["form"].validate(valid => {
  232. if (valid) {
  233. if (this.form.id != null) {
  234. updateIssue(this.form).then(response => {
  235. this.$modal.msgSuccess("修改成功");
  236. this.open = false;
  237. this.getList();
  238. });
  239. } else {
  240. addIssue(this.form).then(response => {
  241. this.$modal.msgSuccess("新增成功");
  242. this.open = false;
  243. this.getList();
  244. });
  245. }
  246. }
  247. });
  248. },
  249. /** 删除按钮操作 */
  250. handleDelete(row) {
  251. const ids = row.id || this.ids;
  252. this.$modal.confirm('是否确认删除?').then(function() {
  253. return delIssue(ids);
  254. }).then(() => {
  255. this.getList();
  256. this.$modal.msgSuccess("删除成功");
  257. }).catch(() => {});
  258. },
  259. }
  260. };
  261. </script>