index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <template>
  2. <div class="app-container">
  3. <el-form v-show="showSearch" ref="queryForm" :inline="true" :model="queryParams" label-width="68px" size="small">
  4. <el-form-item label="被检查设施名称" label-width="120" prop="devName">
  5. <el-input
  6. v-model="queryParams.devName"
  7. clearable
  8. placeholder="请输入被检查设施名称"
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <!-- <el-form-item label="检查周期" prop="checkCycle">
  13. <el-select v-model="queryParams.checkCycle" placeholder="请选择检查周期"
  14. @change="handleQuery">
  15. <el-option
  16. v-for="dict in dict.type.inspection_cycle"
  17. :key="dict.value"
  18. :label="dict.label"
  19. :value="dict.value"
  20. ></el-option>
  21. </el-select>
  22. </el-form-item>-->
  23. <el-form-item label="年" prop="year">
  24. <el-date-picker
  25. v-model="year"
  26. :clearable="false"
  27. placeholder="请选择年份"
  28. type="year"
  29. @change="handleQuery">
  30. </el-date-picker>
  31. </el-form-item>
  32. <el-form-item label="检查责任人" label-width="120" prop="personLiable">
  33. <el-input
  34. v-model="queryParams.personLiable"
  35. clearable
  36. placeholder="请输入检查责任人"
  37. @keyup.enter.native="handleQuery"
  38. />
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button icon="el-icon-search" size="mini" type="primary" @click="handleQuery">搜索</el-button>
  42. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  43. </el-form-item>
  44. </el-form>
  45. <el-row :gutter="10" class="mb8">
  46. <el-col :span="1.5">
  47. <el-button
  48. v-hasPermi="['ps:patrol:add']"
  49. icon="el-icon-plus"
  50. plain
  51. size="mini"
  52. type="primary"
  53. @click="handleAdd"
  54. >新增
  55. </el-button>
  56. </el-col>
  57. <el-col :span="1.5">
  58. <el-button
  59. v-hasPermi="['ps:patrol:export']"
  60. icon="el-icon-download"
  61. plain
  62. size="mini"
  63. type="warning"
  64. @click="handleExport"
  65. >导出
  66. </el-button>
  67. </el-col>
  68. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  69. </el-row>
  70. <el-table v-loading="loading" :data="mainList" :height="clientHeight" border
  71. @selection-change="handleSelectionChange">
  72. <el-table-column align="center" type="selection" width="55"/>
  73. <el-table-column align="center" label="被检查设施名称" prop="devName" width="180"/>
  74. <el-table-column align="center" label="设施数量" prop="devNum" width="100"/>
  75. <el-table-column align="center" label="检查周期" prop="checkCycle" width="140">
  76. <template slot-scope="scope">
  77. <dict-tag :options="dict.type.inspection_cycle" :value="scope.row.checkCycle"/>
  78. </template>
  79. </el-table-column>
  80. <el-table-column :label="'年度:'+queryParams.year" align="center" prop="year">
  81. <el-table-column align="center" label="一月" prop="jan" width="100">
  82. <template slot-scope="scope">
  83. <div v-for=" item in scope.row.jan.split(',')" class="monthStyle" @click="toLink(scope.row.devLink,0)">
  84. <dict-tag :options="dict.type.inspection_status" :value="item"/>
  85. </div>
  86. </template>
  87. </el-table-column>
  88. <el-table-column align="center" label="二月" prop="feb" width="100">
  89. <template slot-scope="scope">
  90. <div v-for=" item in scope.row.feb.split(',')" class="monthStyle" @click="toLink(scope.row.devLink,1)">
  91. <dict-tag :options="dict.type.inspection_status" :value="item"/>
  92. </div>
  93. </template>
  94. </el-table-column>
  95. <el-table-column align="center" label="三月" prop="mar" width="100">
  96. <template slot-scope="scope">
  97. <div v-for=" item in scope.row.mar.split(',')" class="monthStyle" @click="toLink(scope.row.devLink,2)">
  98. <dict-tag :options="dict.type.inspection_status" :value="item"/>
  99. </div>
  100. </template>
  101. </el-table-column>
  102. <el-table-column align="center" label="四月" prop="apr" width="100">
  103. <template slot-scope="scope">
  104. <div v-for=" item in scope.row.apr.split(',')" class="monthStyle" @click="toLink(scope.row.devLink,3)">
  105. <dict-tag :options="dict.type.inspection_status" :value="item"/>
  106. </div>
  107. </template>
  108. </el-table-column>
  109. <el-table-column align="center" label="五月" prop="may" width="100">
  110. <template slot-scope="scope">
  111. <div v-for=" item in scope.row.may.split(',')" class="monthStyle" @click="toLink(scope.row.devLink,4)">
  112. <dict-tag :options="dict.type.inspection_status" :value="item"/>
  113. </div>
  114. </template>
  115. </el-table-column>
  116. <el-table-column align="center" label="六月" prop="jun" width="100">
  117. <template slot-scope="scope">
  118. <div v-for=" item in scope.row.jun.split(',')" class="monthStyle" @click="toLink(scope.row.devLink,5)">
  119. <dict-tag :options="dict.type.inspection_status" :value="item"/>
  120. </div>
  121. </template>
  122. </el-table-column>
  123. <el-table-column align="center" label="七月" prop="jul" width="100">
  124. <template slot-scope="scope">
  125. <div v-for=" item in scope.row.jul.split(',')" class="monthStyle" @click="toLink(scope.row.devLink,6)">
  126. <dict-tag :options="dict.type.inspection_status" :value="item"/>
  127. </div>
  128. </template>
  129. </el-table-column>
  130. <el-table-column align="center" label="八月" prop="aug" width="100">
  131. <template slot-scope="scope">
  132. <div v-for=" item in scope.row.aug.split(',')" class="monthStyle" @click="toLink(scope.row.devLink,7)">
  133. <dict-tag :options="dict.type.inspection_status" :value="item"/>
  134. </div>
  135. </template>
  136. </el-table-column>
  137. <el-table-column align="center" label="九月" prop="sep" width="100">
  138. <template slot-scope="scope">
  139. <div v-for=" item in scope.row.sep.split(',')" class="monthStyle" @click="toLink(scope.row.devLink,8)">
  140. <dict-tag :options="dict.type.inspection_status" :value="item"/>
  141. </div>
  142. </template>
  143. </el-table-column>
  144. <el-table-column align="center" label="十月" prop="oct" width="100">
  145. <template slot-scope="scope">
  146. <div v-for=" item in scope.row.oct.split(',')" class="monthStyle" @click="toLink(scope.row.devLink,9)">
  147. <dict-tag :options="dict.type.inspection_status" :value="item"/>
  148. </div>
  149. </template>
  150. </el-table-column>
  151. <el-table-column align="center" label="十一月" prop="nov" width="100">
  152. <template slot-scope="scope">
  153. <div v-for=" item in scope.row.nov.split(',')" class="monthStyle" @click="toLink(scope.row.devLink,10)">
  154. <dict-tag :options="dict.type.inspection_status" :value="item"/>
  155. </div>
  156. </template>
  157. </el-table-column>
  158. <el-table-column align="center" label="十二月" prop="dec" width="100">
  159. <template slot-scope="scope">
  160. <div v-for=" item in scope.row.dec.split(',')" class="monthStyle" @click="toLink(scope.row.devLink,11)">
  161. <dict-tag :options="dict.type.inspection_status" :value="item"/>
  162. </div>
  163. </template>
  164. </el-table-column>
  165. </el-table-column>
  166. <el-table-column align="center" label="检查责任人" prop="personLiable" width="180"/>
  167. <el-table-column align="center" label="备注" prop="remarks" width="120"/>
  168. <el-table-column label="操作" align="center" width="140" fixed="right" class-name="small-padding fixed-width">
  169. <template slot-scope="scope">
  170. <el-button
  171. size="mini"
  172. type="text"
  173. icon="el-icon-edit"
  174. @click="handleUpdate(scope.row)"
  175. v-hasPermi="['ps:patrol:edit']"
  176. >修改
  177. </el-button>
  178. <el-button
  179. size="mini"
  180. type="text"
  181. icon="el-icon-delete"
  182. @click="handleDelete(scope.row)"
  183. v-hasPermi="['ps:patrol:remove']"
  184. >删除
  185. </el-button>
  186. </template>
  187. </el-table-column>
  188. </el-table>
  189. <pagination
  190. v-show="total>0"
  191. :limit.sync="queryParams.pageSize"
  192. :page.sync="queryParams.pageNum"
  193. :total="total"
  194. @pagination="getList"
  195. />
  196. <!-- 添加或修改消气防设施和器材检查计划总对话框 -->
  197. <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" append-to-body width="30%">
  198. <el-form ref="form" :model="form" :rules="rules" label-width="140px">
  199. <el-form-item label="检查设施" prop="patrolType">
  200. <el-select v-model="form.patrolType" clearable placeholder="请选择检查设施" @change="setDevType">
  201. <el-option
  202. v-for="dict in dict.type.ps_patrol_type"
  203. :key="dict.value"
  204. :label="dict.label"
  205. :value="dict.value"
  206. ></el-option>
  207. </el-select>
  208. </el-form-item>
  209. <el-form-item label="设施数量" prop="devNum">
  210. <el-input v-model="form.devNum" placeholder="请输入设施数量"/>
  211. </el-form-item>
  212. <el-form-item label="检查周期" prop="checkCycle">
  213. <el-select v-model="form.checkCycle" placeholder="请选择检查周期">
  214. <el-option
  215. v-for="dict in dict.type.inspection_cycle"
  216. :key="dict.value"
  217. :label="dict.label"
  218. :value="dict.value"
  219. ></el-option>
  220. </el-select>
  221. </el-form-item>
  222. <el-form-item label="年" prop="year">
  223. <el-date-picker
  224. v-model="form.year"
  225. type="year"
  226. value-format="yyyy"
  227. placeholder="请选择年份">
  228. </el-date-picker>
  229. </el-form-item>
  230. <el-form-item label="检查责任人" prop="personLiable">
  231. <el-input v-model="form.personLiable" placeholder="请输入检查责任人"/>
  232. </el-form-item>
  233. <el-form-item label="备注" prop="remarks">
  234. <el-input v-model="form.remarks" placeholder="请输入备注"/>
  235. </el-form-item>
  236. </el-form>
  237. <div slot="footer" class="dialog-footer">
  238. <el-button type="primary" @click="submitForm">确 定</el-button>
  239. <el-button @click="cancel">取 消</el-button>
  240. </div>
  241. </el-dialog>
  242. </div>
  243. </template>
  244. <script>
  245. import {addMain, delMain, getMain, listMain, updateMain} from "@/api/ps/patrol/main";
  246. export default {
  247. name: "Main",
  248. dicts: ['inspection_cycle', 'inspection_status', 'ps_patrol_type'],
  249. data() {
  250. return {
  251. year: new Date(),
  252. // 遮罩层
  253. loading: true,
  254. // 选中数组
  255. ids: [],
  256. // 非单个禁用
  257. single: true,
  258. // 非多个禁用
  259. multiple: true,
  260. // 显示搜索条件
  261. showSearch: false,
  262. // 页面高度
  263. clientHeight: 300,
  264. // 总条数
  265. total: 0,
  266. // 消气防设施和器材检查计划总表格数据
  267. mainList: [],
  268. cycleOptions: [],
  269. // 弹出层标题
  270. title: "",
  271. // 是否显示弹出层
  272. open: false,
  273. // 查询参数
  274. queryParams: {
  275. pageNum: 1,
  276. pageSize: 20,
  277. devName: null,
  278. devNum: null,
  279. checkCycle: null,
  280. year: null,
  281. jan: null,
  282. feb: null,
  283. mar: null,
  284. apr: null,
  285. may: null,
  286. jun: null,
  287. jul: null,
  288. aug: null,
  289. sep: null,
  290. oct: null,
  291. nov: null,
  292. dec: null,
  293. personLiable: null,
  294. createrCode: null,
  295. createdate: null,
  296. updaterCode: null,
  297. updatedate: null,
  298. remarks: null,
  299. devLink: null,
  300. deptId: null
  301. },
  302. // 表单参数
  303. form: {},
  304. // 表单校验
  305. rules: {}
  306. };
  307. },
  308. created() {
  309. this.getList();
  310. //设置表格高度对应屏幕高度
  311. this.$nextTick(() => {
  312. this.clientHeight = document.body.clientHeight - 270
  313. });
  314. },
  315. methods: {
  316. setDevType(value) {
  317. if (value)
  318. this.form.devName = this.dict.type.ps_patrol_type[value - 1].label;
  319. else
  320. this.form.devName = null;
  321. console.log(this.form.devName)
  322. },
  323. toLink(devLink, month) {
  324. if (devLink) {
  325. this.$router.push({path: devLink, query: {month: month, year: this.year.getFullYear()}});
  326. }
  327. },
  328. /** 查询消气防设施和器材检查计划总列表 */
  329. getList() {
  330. this.loading = true;
  331. this.queryParams.year = this.year.getFullYear();
  332. listMain(this.queryParams).then(response => {
  333. this.mainList = response.rows;
  334. this.total = response.total;
  335. this.loading = false;
  336. });
  337. },
  338. // 取消按钮
  339. cancel() {
  340. this.open = false;
  341. this.reset();
  342. },
  343. // 表单重置
  344. reset() {
  345. this.form = {
  346. id: null,
  347. devName: null,
  348. devNum: null,
  349. checkCycle: null,
  350. year: null,
  351. jan: null,
  352. feb: null,
  353. mar: null,
  354. apr: null,
  355. may: null,
  356. jun: null,
  357. jul: null,
  358. aug: null,
  359. sep: null,
  360. oct: null,
  361. nov: null,
  362. dec: null,
  363. personLiable: null,
  364. delFlag: null,
  365. createrCode: null,
  366. createdate: null,
  367. updaterCode: null,
  368. updatedate: null,
  369. remarks: null,
  370. devLink: null,
  371. deptId: null
  372. };
  373. this.resetForm("form");
  374. },
  375. /** 搜索按钮操作 */
  376. handleQuery() {
  377. this.queryParams.pageNum = 1;
  378. this.getList();
  379. },
  380. /** 重置按钮操作 */
  381. resetQuery() {
  382. this.year = new Date();
  383. this.resetForm("queryForm");
  384. this.handleQuery();
  385. },
  386. // 多选框选中数据
  387. handleSelectionChange(selection) {
  388. this.ids = selection.map(item => item.id)
  389. this.single = selection.length !== 1
  390. this.multiple = !selection.length
  391. },
  392. /** 新增按钮操作 */
  393. handleAdd() {
  394. this.reset();
  395. this.open = true;
  396. this.title = "添加消气防设施和器材检查计划";
  397. },
  398. /** 修改按钮操作 */
  399. handleUpdate(row) {
  400. this.reset();
  401. const id = row.id || this.ids
  402. getMain(id).then(response => {
  403. this.form = response.data;
  404. this.open = true;
  405. this.title = "修改消气防设施和器材检查计划";
  406. });
  407. },
  408. /** 提交按钮 */
  409. submitForm() {
  410. this.$refs["form"].validate(valid => {
  411. if (valid) {
  412. if (this.form.id != null) {
  413. updateMain(this.form).then(response => {
  414. this.msgSuccess("修改成功");
  415. this.open = false;
  416. this.getList();
  417. });
  418. } else {
  419. addMain(this.form).then(response => {
  420. this.msgSuccess("新增成功");
  421. this.open = false;
  422. this.getList();
  423. });
  424. }
  425. }
  426. });
  427. },
  428. /** 删除按钮操作 */
  429. handleDelete(row) {
  430. const ids = row.id || this.ids;
  431. this.$confirm('是否确认数据项?').then(function () {
  432. return delMain(ids);
  433. }).then(() => {
  434. this.getList();
  435. this.msgSuccess("删除成功");
  436. }).catch(() => {
  437. });
  438. },
  439. /** 导出按钮操作 */
  440. handleExport() {
  441. this.download2('patrol/main/export', {
  442. ...this.queryParams
  443. }, `main_${new Date().getTime()}.xlsx`)
  444. },
  445. }
  446. };
  447. </script>
  448. <style>
  449. .monthStyle {
  450. display: inline-block;
  451. }
  452. .monthStyle:hover {
  453. cursor: pointer;
  454. }
  455. </style>