index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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="巡检项ID" prop="busItemsId">-->
  5. <!--<el-input-->
  6. <!--v-model="queryParams.busItemsId"-->
  7. <!--placeholder="请输入巡检项ID"-->
  8. <!--clearable-->
  9. <!--@keyup.enter.native="handleQuery"-->
  10. <!--/>-->
  11. <!--</el-form-item>-->
  12. <!--<el-form-item label="上级ID" prop="parentId">-->
  13. <!--<el-input-->
  14. <!--v-model="queryParams.parentId"-->
  15. <!--placeholder="请输入上级ID"-->
  16. <!--clearable-->
  17. <!--@keyup.enter.native="handleQuery"-->
  18. <!--/>-->
  19. <!--</el-form-item>-->
  20. <el-form-item label="名称" prop="busItemsName">
  21. <el-input
  22. v-model="queryParams.busItemsName"
  23. placeholder="请输入名称"
  24. clearable
  25. @keyup.enter.native="handleQuery"
  26. />
  27. </el-form-item>
  28. <!--<el-form-item label="整改期限" prop="busTimeLimit">-->
  29. <!--<el-input-->
  30. <!--v-model="queryParams.busTimeLimit"-->
  31. <!--placeholder="请输入整改期限"-->
  32. <!--clearable-->
  33. <!--@keyup.enter.native="handleQuery"-->
  34. <!--/>-->
  35. <!--</el-form-item>-->
  36. <!--<el-form-item label="置顶" prop="isTop">-->
  37. <!--<el-input-->
  38. <!--v-model="queryParams.isTop"-->
  39. <!--placeholder="请输入置顶"-->
  40. <!--clearable-->
  41. <!--@keyup.enter.native="handleQuery"-->
  42. <!--/>-->
  43. <!--</el-form-item>-->
  44. <!--<el-form-item label="排序号" prop="other">-->
  45. <!--<el-input-->
  46. <!--v-model="queryParams.other"-->
  47. <!--placeholder="请输入排序号"-->
  48. <!--clearable-->
  49. <!--@keyup.enter.native="handleQuery"-->
  50. <!--/>-->
  51. <!--</el-form-item>-->
  52. <el-form-item>
  53. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  54. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  55. </el-form-item>
  56. </el-form>
  57. <el-row :gutter="10" class="mb8">
  58. <el-col :span="1.5">
  59. <el-button
  60. type="primary"
  61. plain
  62. icon="el-icon-plus"
  63. size="mini"
  64. @click="handleAdd"
  65. v-hasPermi="['system:items:add']"
  66. >新增
  67. </el-button>
  68. </el-col>
  69. <el-col :span="1.5">
  70. <el-button
  71. type="success"
  72. plain
  73. icon="el-icon-edit"
  74. size="mini"
  75. :disabled="single"
  76. @click="handleUpdate"
  77. v-hasPermi="['system:items:edit']"
  78. >修改
  79. </el-button>
  80. </el-col>
  81. <el-col :span="1.5">
  82. <el-button
  83. type="danger"
  84. plain
  85. icon="el-icon-delete"
  86. size="mini"
  87. :disabled="multiple"
  88. @click="handleDelete"
  89. v-hasPermi="['system:items:remove']"
  90. >删除
  91. </el-button>
  92. </el-col>
  93. <el-col :span="1.5">
  94. <el-button
  95. type="warning"
  96. plain
  97. icon="el-icon-download"
  98. size="mini"
  99. @click="handleExport"
  100. v-hasPermi="['system:items:export']"
  101. >导出
  102. </el-button>
  103. </el-col>
  104. <el-col :span="1.5" v-if="items_ceng >0 ">
  105. <el-button
  106. type="warning"
  107. plain
  108. icon="el-icon-download"
  109. size="mini"
  110. @click="back"
  111. >返回
  112. </el-button>
  113. </el-col>
  114. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  115. </el-row>
  116. <el-table v-loading="loading" :data="itemsList" @selection-change="handleSelectionChange">
  117. <el-table-column type="selection" width="55" align="center"/>
  118. <!--<el-table-column label="巡检项ID" align="center" prop="busItemsId" />-->
  119. <!--<el-table-column label="上级ID" align="center" prop="parentId" />-->
  120. <el-table-column label="名称" align="center">
  121. <template slot-scope="scope">
  122. <label style="cursor: pointer;color:#0000ff" v-show="items_ceng <=1" @click="toNext(scope.row.busItemsId)">{{scope.row.busItemsName}}</label>
  123. <label v-show="items_ceng ==2">{{scope.row.busItemsName}}</label>
  124. </template>
  125. </el-table-column>
  126. <el-table-column label="整改期限" align="center" prop="busTimeLimit" v-if="items_ceng == 2">
  127. </el-table-column>
  128. <el-table-column label="置顶" align="center" prop="isTop">
  129. <template slot-scope="scope">
  130. <label v-show="scope.row.isTop == 'N'">否</label>
  131. <label v-show="scope.row.isTop == 'Y'">是</label>
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="排序号" align="center" prop="other"/>
  135. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  136. <template slot-scope="scope">
  137. <el-button
  138. size="mini"
  139. type="text"
  140. icon="el-icon-edit"
  141. @click="handleUpdate(scope.row)"
  142. v-hasPermi="['system:items:edit']"
  143. >修改
  144. </el-button>
  145. <el-button
  146. size="mini"
  147. type="text"
  148. icon="el-icon-delete"
  149. @click="handleDelete(scope.row)"
  150. v-hasPermi="['system:items:remove']"
  151. >删除
  152. </el-button>
  153. </template>
  154. </el-table-column>
  155. </el-table>
  156. <pagination
  157. v-show="total>0"
  158. :total="total"
  159. :page.sync="queryParams.pageNum"
  160. :limit.sync="queryParams.pageSize"
  161. @pagination="getList"
  162. />
  163. <!-- 添加或修改巡检项对话框 -->
  164. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  165. <el-form ref="form" :model="form" :rules="items_ceng == 2 ? rulesItem: rules " label-width="80px">
  166. <!--<el-form-item label="巡检项ID" prop="busItemsId">-->
  167. <!--<el-input v-model="form.busItemsId" placeholder="请输入巡检项ID" />-->
  168. <!--</el-form-item>-->
  169. <!--<el-form-item label="上级ID" prop="parentId">-->
  170. <!--<el-input v-model="form.parentId" placeholder="请输入上级ID" />-->
  171. <!--</el-form-item>-->
  172. <el-form-item label="名称" prop="busItemsName">
  173. <el-input v-model="form.busItemsName" placeholder="请输入名称"/>
  174. </el-form-item>
  175. <el-form-item label="整改期限" prop="busTimeLimit" v-show="items_ceng == 2">
  176. <el-input v-model="form.busTimeLimit" placeholder="请输入整改期限"/>
  177. </el-form-item>
  178. <el-form-item label="置顶" prop="isTop">
  179. <el-select v-model="form.isTop">
  180. <el-option label="否" value="N" sel></el-option>
  181. <el-option label="是" value="Y"></el-option>
  182. </el-select>
  183. </el-form-item>
  184. <el-form-item label="排序号" prop="other">
  185. <el-input v-model="form.other" placeholder="请输入排序号"/>
  186. </el-form-item>
  187. </el-form>
  188. <div slot="footer" class="dialog-footer">
  189. <el-button type="primary" @click="submitForm">确 定</el-button>
  190. <el-button @click="cancel">取 消</el-button>
  191. </div>
  192. </el-dialog>
  193. </div>
  194. </template>
  195. <script>
  196. import {listItems, getItems, delItems, addItems, updateItems} from "@/api/centerdata_emergency1/items";
  197. export default {
  198. name: "Items",
  199. data() {
  200. return {
  201. items_ceng: 0,
  202. // 遮罩层
  203. loading: true,
  204. // 选中数组
  205. ids: [],
  206. items_names: [],
  207. // 非单个禁用
  208. single: true,
  209. // 非多个禁用
  210. multiple: true,
  211. // 显示搜索条件
  212. showSearch: true,
  213. // 总条数
  214. total: 0,
  215. // 巡检项表格数据
  216. itemsList: [],
  217. // 弹出层标题
  218. title: "",
  219. // 是否显示弹出层
  220. open: false,
  221. // 查询参数
  222. queryParams: {
  223. pageNum: 1,
  224. pageSize: 10,
  225. busItemsId: null,
  226. parentId: null,
  227. busItemsName: null,
  228. busTimeLimit: null,
  229. isTop: null,
  230. other: null
  231. },
  232. // 表单参数
  233. form: {
  234. isTop: 'N'
  235. },
  236. rulesItem:{
  237. other:[
  238. {
  239. pattern: /^\d*$/,
  240. message: "序号必须为数字",
  241. trigger: "blur"
  242. }
  243. ],
  244. busItemsName: [
  245. {
  246. required: true, message: "名称不能为空", trigger: "blur"
  247. },
  248. {min: 1, max: 20, message: '巡检项目名长度必须介于 1 和 20 之间', trigger: 'blur'}
  249. ],
  250. busTimeLimit: [
  251. {
  252. required: true, message: "整改期限不能为空", trigger: "blur"
  253. },
  254. {
  255. pattern: /^\d*$/,
  256. message: "整改期限必须为数字",
  257. trigger: "blur"
  258. }
  259. ]
  260. },
  261. // 表单校验
  262. rules: {
  263. other:[
  264. {
  265. pattern: /^\d*$/,
  266. message: "序号必须为数字",
  267. trigger: "blur"
  268. }
  269. ],
  270. busItemsName: [
  271. {
  272. required: true, message: "名称不能为空", trigger: "blur"
  273. },
  274. {min: 1, max: 20, message: '巡检项目名长度必须介于 1 和 20 之间', trigger: 'blur'}
  275. ],
  276. }
  277. };
  278. },
  279. created() {
  280. this.queryParams.parentId = this.$route.query.parent_id
  281. this.items_ceng = this.$route.query.items_ceng
  282. this.getList();
  283. },
  284. watch: {
  285. $route() {
  286. this.queryParams.parentId = this.$route.query.parent_id
  287. this.items_ceng = this.$route.query.items_ceng
  288. this.getList();
  289. }
  290. },
  291. methods: {
  292. back() {
  293. this.$router.go(-1)
  294. },
  295. toNext(busItemsId) {
  296. this.items_ceng++;
  297. this.$router.push({
  298. path: '',
  299. query: {"parent_id": busItemsId, "items_ceng": this.items_ceng}
  300. })
  301. },
  302. /** 查询巡检项列表 */
  303. getList() {
  304. this.loading = true;
  305. listItems(this.queryParams).then(response => {
  306. this.itemsList = response.rows;
  307. this.total = response.total;
  308. this.loading = false;
  309. });
  310. },
  311. // 取消按钮
  312. cancel() {
  313. this.open = false;
  314. this.reset();
  315. },
  316. // 表单重置
  317. reset() {
  318. this.form = {
  319. busItemsId: null,
  320. parentId: this.queryParams.parentId,
  321. busItemsName: null,
  322. busTimeLimit: null,
  323. isTop: 'N',
  324. other: null
  325. };
  326. this.resetForm("form");
  327. },
  328. /** 搜索按钮操作 */
  329. handleQuery() {
  330. this.queryParams.pageNum = 1;
  331. this.getList();
  332. },
  333. /** 重置按钮操作 */
  334. resetQuery() {
  335. this.resetForm("queryForm");
  336. this.handleQuery();
  337. },
  338. // 多选框选中数据
  339. handleSelectionChange(selection) {
  340. this.ids = selection.map(item => item.busItemsId)
  341. this.items_names = selection.map(item => item.busItemsName)
  342. this.single = selection.length !== 1
  343. this.multiple = !selection.length
  344. },
  345. /** 新增按钮操作 */
  346. handleAdd() {
  347. this.reset();
  348. this.open = true;
  349. this.title = "添加巡检项";
  350. },
  351. /** 修改按钮操作 */
  352. handleUpdate(row) {
  353. this.reset();
  354. const busItemsId = row.busItemsId || this.ids
  355. getItems(busItemsId).then(response => {
  356. this.form = response.data;
  357. this.open = true;
  358. this.title = "修改巡检项";
  359. });
  360. },
  361. /** 提交按钮 */
  362. submitForm() {
  363. console.log("kkkkkkk")
  364. this.$refs["form"].validate(valid => {
  365. console.log("1111111", valid)
  366. if (valid) {
  367. if (this.form.busItemsId != null) {
  368. updateItems(this.form).then(response => {
  369. this.$modal.msgSuccess("修改成功");
  370. this.open = false;
  371. this.getList();
  372. });
  373. } else {
  374. addItems(this.form).then(response => {
  375. this.$modal.msgSuccess("新增成功");
  376. this.open = false;
  377. this.getList();
  378. });
  379. }
  380. }
  381. });
  382. },
  383. /** 删除按钮操作 */
  384. handleDelete(row) {
  385. const busItemsIds = row.busItemsId || this.ids;
  386. const busItemsName = row.busItemsName || this.items_names
  387. this.$modal.confirm('是否确认删除巡检项为"' + busItemsName + '"的数据项?').then(function () {
  388. return delItems(busItemsIds);
  389. }).then(() => {
  390. this.getList();
  391. this.$modal.msgSuccess("删除成功");
  392. }).catch(() => {
  393. });
  394. },
  395. /** 导出按钮操作 */
  396. handleExport() {
  397. let path;
  398. if (this.items_ceng == 2) {
  399. path = 'system/items/export'
  400. } else {
  401. path = 'system/items/export12'
  402. }
  403. this.download(path, {
  404. ...this.queryParams
  405. }, `items_${new Date().getTime()}.xlsx`)
  406. }
  407. }
  408. };
  409. </script>