index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <template>
  2. <div style="padding: 10px">
  3. <div class="formbody">
  4. <el-form
  5. :inline="true"
  6. v-model="queryparameters"
  7. class="demo-form-inline"
  8. >
  9. <el-form-item label="设施台账">
  10. <el-select
  11. v-model="queryparameters.facilitiesId"
  12. class="m-1"
  13. placeholder="请选择"
  14. >
  15. <el-option
  16. v-for="item in alldevices"
  17. :label="item.exId"
  18. :value="item.exId"
  19. ></el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="计划状态" v-if="currentstatus == 1">
  23. <el-select
  24. v-model="queryparameters.status"
  25. class="m-1"
  26. placeholder="请选择"
  27. >
  28. <el-option
  29. v-for="item in detection_status"
  30. :label="item.label"
  31. :value="item.value"
  32. ></el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="道路名">
  36. <el-select
  37. v-model="queryparameters.taskArea"
  38. class="m-2"
  39. placeholder="请选择"
  40. >
  41. <el-option
  42. v-for="item in alldevices"
  43. :label="item.roadName"
  44. :value="item.roadName"
  45. ></el-option>
  46. </el-select>
  47. </el-form-item>
  48. <div style="float: right">
  49. <el-form-item>
  50. <el-button type="primary" @click="getList">查询</el-button>
  51. </el-form-item>
  52. <el-form-item>
  53. <el-button type="success" @click="adddetection">新增</el-button>
  54. </el-form-item>
  55. </div>
  56. </el-form>
  57. <div>
  58. <el-table
  59. :data="tableData"
  60. class="eltable"
  61. style="width: 100%"
  62. @row-click="tblrowclick"
  63. >
  64. <el-table-column label="设备台账">
  65. <template #default="scope">
  66. {{
  67. alldevices.filter((i) => i.id === scope.row.facilitiesId)[0]
  68. ?.exId ?? "-"
  69. }}
  70. </template>
  71. </el-table-column>
  72. <el-table-column prop="taskCode" label="设施道路">
  73. <template #default="scope">
  74. {{
  75. alldevices.filter((i) => i.id === scope.row.facilitiesId)[0]
  76. ?.roadName ?? "-"
  77. }}
  78. </template>
  79. </el-table-column>
  80. <el-table-column prop="detectionYear" label="年计划" width="180" />
  81. <el-table-column prop="detectionMonth" label="月计划" width="180" />
  82. <el-table-column label="运维设施长度" width="180">
  83. <template #default="scope">
  84. {{
  85. alldevices.filter((i) => i.id === scope.row.facilitiesId)[0]
  86. ?.fLength ?? ""
  87. }}
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="计划状态" width="180">
  91. <template #default="scope">
  92. {{
  93. detection_status.filter(
  94. (i) => i.value.toString() === scope.row.status.toString()
  95. )[0]?.label ?? "-"
  96. }}
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="检测类型">
  100. <template #default="scope">
  101. {{
  102. detection_type.filter(
  103. (i) => i.value.toString() === scope.row.detectionType.toString()
  104. )[0]?.label ?? "-"
  105. }}
  106. </template>
  107. </el-table-column>
  108. <el-table-column prop="address" label="操作">
  109. <template #default="scope">
  110. <el-button text size="small" @click.stop="edittask(scope.row)"
  111. >修改
  112. </el-button>
  113. <el-popconfirm title="确定删除?" @confirm="deltask(scope.row)">
  114. <template #reference>
  115. <el-button text size="small" @click.stop="">删除</el-button>
  116. </template>
  117. </el-popconfirm>
  118. </template>
  119. </el-table-column>
  120. <!-- <el-table-column prop="ext1" label="责任人" width="180">
  121. <template #default="scope">
  122. {{ scope.row.ext1 === "" ? "未派发" : scope.row.ext1 }}
  123. </template>
  124. </el-table-column> -->
  125. </el-table>
  126. <div style="position: relative; padding-right: 20px; margin-top: -20px">
  127. <Pagination
  128. :total="pagedata.total ?? 0"
  129. v-show="pagedata.total > 0"
  130. v-model:page="queryparameters.pageNum"
  131. v-model:limit="queryparameters.pageSize"
  132. @pagination="getList"
  133. ></Pagination>
  134. <!-- <el-pagination
  135. style="float: right"
  136. small
  137. background
  138. :page-sizes="[10, 20, 30, 50]"
  139. :page-size="10"
  140. layout=" sizes,prev, pager, next"
  141. :total="pagedata.total??0"
  142. class="mt-4"
  143. /> -->
  144. </div>
  145. </div>
  146. </div>
  147. <el-dialog
  148. v-model="showadd"
  149. v-loading="loading"
  150. title="新增检测计划"
  151. width="70%"
  152. draggable
  153. >
  154. <div>
  155. <el-form :model="detectioninfo">
  156. <el-row>
  157. <el-col :span="12">
  158. <el-form-item label="关联设施" label-width="150px">
  159. <el-select
  160. v-model="detectioninfo.facilitiesId"
  161. filterable
  162. placeholder="请选择"
  163. >
  164. <el-option
  165. v-for="item in alldevices"
  166. :label="item.name"
  167. :value="item.id"
  168. ></el-option>
  169. </el-select>
  170. </el-form-item>
  171. </el-col>
  172. <el-col :span="12">
  173. <el-form-item label="检测类型" label-width="150px">
  174. <el-select
  175. v-model="detectioninfo.detectionType"
  176. filterable
  177. placeholder="请选择类型"
  178. >
  179. <el-option
  180. v-for="item in detection_type"
  181. :label="item.label"
  182. :value="parseInt(item.value)"
  183. ></el-option>
  184. </el-select>
  185. </el-form-item>
  186. </el-col>
  187. </el-row>
  188. <el-row>
  189. <el-col :span="8">
  190. <el-form-item label="计划年" label-width="150px">
  191. <el-select
  192. v-model="detectioninfo.detectionYear"
  193. filterable
  194. placeholder="请选择计划年"
  195. >
  196. <el-option
  197. v-for="item in getyears()"
  198. :label="item"
  199. :value="item"
  200. ></el-option>
  201. </el-select> </el-form-item
  202. ></el-col>
  203. <el-col :span="8">
  204. <el-form-item label="计划月" label-width="150px">
  205. <el-select
  206. v-model="detectioninfo.detectionMonth"
  207. filterable
  208. placeholder="请选择计划月"
  209. >
  210. <el-option
  211. v-for="item in getmonth()"
  212. :label="item"
  213. :value="item"
  214. ></el-option> </el-select></el-form-item
  215. ></el-col>
  216. <el-col :span="8">
  217. <el-form-item label="计划周" label-width="150px">
  218. <el-input
  219. v-model="detectioninfo.detectionWeek"
  220. placeholder="请输入周"
  221. ></el-input> </el-form-item
  222. ></el-col>
  223. </el-row>
  224. <el-row>
  225. <el-col :span="12"
  226. ><el-form-item label="计划作业组" label-width="150px">
  227. <el-tree-select
  228. v-model="detectioninfo.detectionDept"
  229. multiple
  230. :data="treedept"
  231. check-strictly="true"
  232. /> </el-form-item
  233. ></el-col>
  234. <el-col :span="12"
  235. ><el-form-item label="计划备注" label-width="150px">
  236. <el-input
  237. v-model="detectioninfo.detectionDes"
  238. type="textarea"
  239. placeholder="请输入"
  240. ></el-input> </el-form-item
  241. ></el-col>
  242. </el-row>
  243. <el-row>
  244. <el-col :span="24"
  245. ><el-form-item label="备注" label-width="150px">
  246. <el-input
  247. v-model="detectioninfo.detectionRemark"
  248. type="textarea"
  249. placeholder="请输入"
  250. ></el-input> </el-form-item
  251. ></el-col>
  252. </el-row>
  253. </el-form>
  254. </div>
  255. <template #footer>
  256. <span class="dialog-footer">
  257. <el-button @click="showadd = false">取消</el-button>
  258. <el-button type="primary" @click="onadd">保存</el-button>
  259. </span>
  260. </template>
  261. </el-dialog>
  262. </div>
  263. </template>
  264. <script setup>
  265. import { defineComponent, ref, reactive, onMounted, computed } from "vue";
  266. import { useDict } from "@/utils/dict";
  267. import router from "../../../router";
  268. // 分页组件
  269. import Pagination from "@/components/Pagination";
  270. import { listFacilities } from "@/api/system/facilities";
  271. import { listDetection,addDetection } from "@/api/system/detection";
  272. import { listDept, getDept } from "@/api/system/dept";
  273. import { treeselect as deptTreeselect } from "@/api/system/dept";
  274. import { cloneDeep } from "lodash";
  275. import { ElMessage } from "element-plus";
  276. import { useRoute } from "vue-router";
  277. import { delDetection, updateDetection } from "../../../api/system/detection";
  278. const { detection_status, detection_type } = useDict(
  279. "detection_status",
  280. "detection_type"
  281. );
  282. const queryparameters = ref({
  283. status: "",
  284. facilitiesId: "",
  285. pageNum: 1,
  286. pageSize: 10,
  287. });
  288. const { proxy } = getCurrentInstance();
  289. const showadd = ref(false);
  290. const loading = ref(false);
  291. const tableData = ref([]);
  292. const pagedata = ref({});
  293. const route = useRoute();
  294. const currentstatus = computed(() => route.params.status);
  295. const alldevices = ref([]);
  296. listFacilities().then((res) => {
  297. alldevices.value = res.rows;
  298. });
  299. const detectioninfo = ref({});
  300. const maintaininfo = ref();
  301. const initadd = () => {
  302. detectioninfo.value = {
  303. detectionDept: "",
  304. detectionDes: "",
  305. detectionLogs: null,
  306. detectionMonth: "",
  307. detectionRemark: "",
  308. detectionType: null,
  309. detectionWeek: "",
  310. detectionYear: "",
  311. ext1: "",
  312. ext2: "",
  313. id:null,
  314. facilitiesId: 1,
  315. remark: null,
  316. status: 1,
  317. };
  318. };
  319. initadd();
  320. const adddetection = () => {
  321. initadd();
  322. showadd.value = true;
  323. };
  324. const tblrowclick = (row) => {
  325. // console.log(row)
  326. router.push(`/detection/detail/${row.id}`);
  327. };
  328. const onadd = () => {
  329. loading.value = true;
  330. if (detectioninfo.value.id == null) {
  331. var detectioninfoobj = cloneDeep(detectioninfo.value);
  332. // delete detectioninfoobj.detectionDept;
  333. detectioninfoobj.detectionDept = (detectioninfo.value.detectionDept instanceof Array) ? detectioninfo.value.detectionDept.join(",") : '';
  334. addDetection(detectioninfoobj).then(res => {
  335. loading.value = false;
  336. showadd.value = false;
  337. getList();
  338. })
  339. } else {
  340. var detectioninfoobj = cloneDeep(detectioninfo.value);
  341. // delete detectioninfoobj.detectionDept;
  342. detectioninfoobj.detectionDept = (detectioninfo.value.detectionDept instanceof Array) ? detectioninfo.value.detectionDept.join(",") : '';
  343. updateDetection(detectioninfoobj).then(res => {
  344. loading.value = false;
  345. showadd.value = false;
  346. getList();
  347. })
  348. }
  349. };
  350. const getList = () => {
  351. if (currentstatus.value != 1) {
  352. if (currentstatus.value == 2) {
  353. queryparameters.value.status = 1;
  354. } else {
  355. queryparameters.value.status = currentstatus.value;
  356. }
  357. } else {
  358. queryparameters.value.status = "";
  359. }
  360. listDetection(queryparameters.value).then((response) => {
  361. tableData.value = response.rows;
  362. pagedata.value = response;
  363. });
  364. };
  365. getList();
  366. const getyears = () => {
  367. var years = [];
  368. for (var i = 0; i <= 100; i++) {
  369. years.push((2019 + i).toString());
  370. }
  371. return years;
  372. };
  373. const getmonth = () => {
  374. var months = [];
  375. for (var i = 0; i < 12; i++) {
  376. if (i < 9) {
  377. months.push("0" + (1 + i).toString());
  378. } else {
  379. months.push((1 + i).toString());
  380. }
  381. }
  382. return months;
  383. };
  384. const edittask = (row) => {
  385. detectioninfo.value = cloneDeep(row);
  386. if (detectioninfo.value.detectionDept!=null && detectioninfo.value.detectionDept!="" && detectioninfo.value.detectionDept!=undefined && !Array.isArray(detectioninfo.value.detectionDept)) {
  387. detectioninfo.value.detectionDept = detectioninfo.value.detectionDept.split(",").map(i => parseInt(i));
  388. }
  389. showadd.value = true;
  390. };
  391. const deltask = (row) => {
  392. delDetection(row.id).then((res) => {
  393. ElMessage.success("删除成功");
  394. getList();
  395. });
  396. };
  397. onMounted(() => {});
  398. function setdatakey(dept) {
  399. if (dept.children) {
  400. dept.children = dept.children.map((i) => {
  401. return setdatakey(i);
  402. });
  403. }
  404. dept["value"] = dept.id;
  405. return dept;
  406. }
  407. const treedept = ref([]);
  408. deptTreeselect().then((res) => {
  409. treedept.value = [setdatakey(res.data[0])];
  410. });
  411. </script>
  412. <style lang="scss" scoped>
  413. .formbody {
  414. background: #fff;
  415. width: 100%;
  416. border-radius: 5px;
  417. min-height: 80vh;
  418. padding: 15px 10px;
  419. .eltable {
  420. border: 1px solid #e5e9f2;
  421. border-radius: 5px;
  422. }
  423. }
  424. </style>
  425. <style>
  426. .el-table__row:hover {
  427. cursor: pointer;
  428. }
  429. .el-select {
  430. width: 100%;
  431. }
  432. </style>