index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="位置" prop="position">
  5. <el-input
  6. v-model="queryParams.position"
  7. placeholder="请输入位置"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="年" prop="planYear">
  13. <el-date-picker
  14. v-model="year"
  15. :clearable="false"
  16. format="yyyy"
  17. placeholder="请选择年份"
  18. type="year"
  19. @change="handleQuery">
  20. </el-date-picker>
  21. </el-form-item>
  22. <el-form-item label="月" prop="planQuarter">
  23. <el-date-picker
  24. v-model="month"
  25. :clearable="false"
  26. format="MM"
  27. placeholder="选择月"
  28. popper-class="picker-date"
  29. type="month"
  30. @change="handleQuery">
  31. </el-date-picker>
  32. </el-form-item>
  33. <el-form-item label="计划名称" prop="planId">
  34. <el-select v-model="queryParams.planId" clearable
  35. @change="handleQuery">
  36. <el-option v-for="item in planList"
  37. :key="item.id"
  38. :label="item.planName"
  39. :value="item.id"/>
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item>
  43. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  44. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  45. </el-form-item>
  46. </el-form>
  47. <el-row :gutter="10" class="mb8">
  48. <el-col :span="1.5">
  49. <el-button
  50. type="warning"
  51. plain
  52. icon="el-icon-download"
  53. size="mini"
  54. @click="handleExport"
  55. v-hasPermi="['commonuse:downspout:export']"
  56. >导出</el-button>
  57. </el-col>
  58. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  59. </el-row>
  60. <el-table v-loading="loading" :data="downspoutList" :height="clientHeight" @selection-change="handleSelectionChange" border>
  61. <el-table-column type="selection" width="55" align="center" />
  62. <el-table-column label="位置" align="center" prop="position" />
  63. <el-table-column label="落水管外观" align="center" prop="appearance">
  64. <template slot-scope="scope">
  65. <dict-tag :options="dict.type.inspection_status" :value="scope.row.appearance"/>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="管道是否破损" align="center" prop="damaged">
  69. <template slot-scope="scope">
  70. <dict-tag :options="dict.type.inspection_status" :value="scope.row.damaged"/>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="紧固件是否松动" align="center" prop="becomeFlexible">
  74. <template slot-scope="scope">
  75. <dict-tag :options="dict.type.inspection_status" :value="scope.row.becomeFlexible"/>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="确认人" align="center" prop="confirmed" />
  79. <el-table-column label="备注" align="center" prop="remarks" />
  80. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  81. <template slot-scope="scope">
  82. <el-button
  83. icon="el-icon-picture-outline"
  84. size="mini"
  85. type="text"
  86. @click="openFileDialog(scope.row)"
  87. >附件
  88. </el-button>
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <el-dialog :close-on-click-modal="false":visible.sync="file.open" append-to-body title="附件详情" width="50%">
  93. <el-tabs v-model="tabName" :stretch="true" type="border-card">
  94. <el-tab-pane label="常规附件" name="a">
  95. <el-empty v-if="file.files.length==0" description="如你所见,这里什么都没有"></el-empty>
  96. <el-image v-for="url in file.files" v-else :key="url" :src="url"></el-image>
  97. </el-tab-pane>
  98. <el-tab-pane label="异常附件" name="b">
  99. <el-empty v-if="file.issuesFiles.length==0" description="如你所见,这里什么都没有"></el-empty>
  100. <el-image v-for="url in file.issuesFiles" v-else :key="url" :src="url"></el-image>
  101. </el-tab-pane>
  102. <el-tab-pane label="异常整改后附件" name="c">
  103. <el-empty v-if="file.repairFile.length==0" description="如你所见,这里什么都没有"></el-empty>
  104. <el-image v-for="url in file.repairFile" v-else :key="url" :src="url"></el-image>
  105. </el-tab-pane>
  106. </el-tabs>
  107. </el-dialog>
  108. <pagination
  109. v-show="total>0"
  110. :total="total"
  111. :page.sync="queryParams.pageNum"
  112. :limit.sync="queryParams.pageSize"
  113. @pagination="getList"
  114. />
  115. </div>
  116. </template>
  117. <script>
  118. import { listDownspout, getDownspout, delDownspout, addDownspout, updateDownspout } from "@/api/patrol/commonuse/downspout";
  119. import {listAllPlan} from "@/api/patrol/patrol/plan";
  120. export default {
  121. name: "Downspout",
  122. dicts: ['inspection_status'],
  123. data() {
  124. return {
  125. tabName: 'a',
  126. planList: [],
  127. file: {
  128. open: false,
  129. issuesFiles: [],
  130. repairFile: [],
  131. files: []
  132. },
  133. month: new Date(),
  134. year: new Date(),
  135. // 遮罩层
  136. loading: true,
  137. // 选中数组
  138. ids: [],
  139. // 非单个禁用
  140. single: true,
  141. // 非多个禁用
  142. multiple: true,
  143. // 显示搜索条件
  144. showSearch: false,
  145. // 页面高度
  146. clientHeight: 300,
  147. // 总条数
  148. total: 0,
  149. // 落水管表格数据
  150. downspoutList: [],
  151. // 弹出层标题
  152. title: "",
  153. // 是否显示弹出层
  154. open: false,
  155. // 查询参数
  156. queryParams: {
  157. pageNum: 1,
  158. pageSize: 20,
  159. id: null,
  160. position: null,
  161. appearance: null,
  162. damaged: null,
  163. becomeFlexible: null,
  164. confirmed: null,
  165. remarks: null,
  166. checkStatus: null,
  167. checkDate: null,
  168. month: null,
  169. year: null,
  170. createrCode: null,
  171. createdate: null,
  172. updaterCode: null,
  173. updatedate: null,
  174. deptId: null,
  175. planId: null,
  176. problemFileUrl: null,
  177. fileUrl: null,
  178. issuesStatus: null,
  179. issuesFlag: null,
  180. repairFile: null
  181. },
  182. // 表单参数
  183. form: {},
  184. // 表单校验
  185. rules: {
  186. }
  187. };
  188. },
  189. created() {
  190. if (this.$route.query.year && this.$route.query.month) {
  191. this.year.setFullYear(this.$route.query.year, this.$route.query.month, 1);
  192. this.month.setMonth(this.$route.query.month, 1);
  193. }
  194. if (this.$route.query.planId) {
  195. this.queryParams.planId = parseInt(this.$route.query.planId)
  196. }
  197. if (this.$route.query.id) {
  198. this.queryParams.id = parseInt(this.$route.query.id)
  199. this.queryParams.issuesFlag = '1';
  200. }
  201. //设置表格高度对应屏幕高度
  202. this.$nextTick(() => {
  203. this.clientHeight = document.body.clientHeight - 270
  204. });
  205. if (!this.queryParams.id) {
  206. let query = {planQuarter: this.month.getMonth() + 1, planYear: this.year.getFullYear(), patrolType: '25'}
  207. listAllPlan(query).then(res => {
  208. this.planList = res.data;
  209. if (res.data.length > 0) {
  210. this.queryParams.planId = res.data[0].id;
  211. }
  212. this.getList();
  213. })
  214. }else{
  215. this.getList();
  216. }
  217. },
  218. methods: {
  219. openFileDialog(row) {
  220. this.tabName = 'a'
  221. this.file.issuesFiles = []
  222. this.file.files = []
  223. this.file.repairFile = []
  224. this.file.open = true;
  225. if (row.problemFileUrl) {
  226. this.file.issuesFiles = row.problemFileUrl.split(',').map(item => process.env.VUE_APP_BASE_API + item);
  227. }
  228. if (row.fileUrl) {
  229. this.file.files = row.fileUrl.split(',').map(item => process.env.VUE_APP_BASE_API + item);
  230. }
  231. if (row.repairFile) {
  232. this.file.repairFile = row.repairFile.split(',').map(item => process.env.VUE_APP_BASE_API + item);
  233. }
  234. },
  235. getPlanList() {
  236. let query = {planQuarter: this.month.getMonth() + 1, planYear: this.year.getFullYear(), patrolType: '25'}
  237. listAllPlan(query).then(res => {
  238. this.planList = res.data;
  239. })
  240. },
  241. /** 查询落水管列表 */
  242. getList() {
  243. this.loading = true;
  244. if (!this.queryParams.id) {
  245. this.queryParams.month = this.month.getMonth() + 1;
  246. this.queryParams.year = this.year.getFullYear();
  247. }
  248. listDownspout(this.queryParams).then(response => {
  249. this.downspoutList = response.rows;
  250. this.total = response.total;
  251. this.loading = false;
  252. });
  253. },
  254. // 取消按钮
  255. cancel() {
  256. this.open = false;
  257. this.reset();
  258. },
  259. // 表单重置
  260. reset() {
  261. this.form = {
  262. id: null,
  263. position: null,
  264. appearance: null,
  265. damaged: null,
  266. becomeFlexible: null,
  267. confirmed: null,
  268. remarks: null,
  269. checkStatus: null,
  270. checkDate: null,
  271. month: null,
  272. year: null,
  273. delFlag: null,
  274. createrCode: null,
  275. createdate: null,
  276. updaterCode: null,
  277. updatedate: null,
  278. deptId: null,
  279. planId: null,
  280. problemFileUrl: null,
  281. fileUrl: null,
  282. issuesStatus: null,
  283. issuesFlag: null,
  284. repairFile: null
  285. };
  286. this.resetForm("form");
  287. },
  288. /** 搜索按钮操作 */
  289. handleQuery() {
  290. this.queryParams.pageNum = 1;
  291. this.getList();
  292. this.getPlanList();
  293. },
  294. /** 重置按钮操作 */
  295. resetQuery() {
  296. this.resetForm("queryForm");
  297. this.handleQuery();
  298. },
  299. // 多选框选中数据
  300. handleSelectionChange(selection) {
  301. this.ids = selection.map(item => item.id)
  302. this.single = selection.length!==1
  303. this.multiple = !selection.length
  304. },
  305. /** 新增按钮操作 */
  306. handleAdd() {
  307. this.reset();
  308. this.open = true;
  309. this.title = "添加落水管";
  310. },
  311. /** 修改按钮操作 */
  312. handleUpdate(row) {
  313. this.reset();
  314. const id = row.id || this.ids
  315. getDownspout(id).then(response => {
  316. this.form = response.data;
  317. this.open = true;
  318. this.title = "修改落水管";
  319. });
  320. },
  321. /** 提交按钮 */
  322. submitForm() {
  323. this.$refs["form"].validate(valid => {
  324. if (valid) {
  325. if (this.form.id != null) {
  326. updateDownspout(this.form).then(response => {
  327. this.msgSuccess("修改成功");
  328. this.open = false;
  329. this.getList();
  330. });
  331. } else {
  332. addDownspout(this.form).then(response => {
  333. this.msgSuccess("新增成功");
  334. this.open = false;
  335. this.getList();
  336. });
  337. }
  338. }
  339. });
  340. },
  341. /** 删除按钮操作 */
  342. handleDelete(row) {
  343. const ids = row.id || this.ids;
  344. this.$confirm('是否确认删除落水管编号为"' + ids + '"的数据项?').then(function() {
  345. return delDownspout(ids);
  346. }).then(() => {
  347. this.getList();
  348. this.msgSuccess("删除成功");
  349. }).catch(() => {});
  350. },
  351. /** 导出按钮操作 */
  352. handleExport() {
  353. this.download2('commonuse/downspout/export', {
  354. ...this.queryParams
  355. }, `downspout_${new Date().getTime()}.xlsx`)
  356. }
  357. }
  358. };
  359. </script>