index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" >
  4. <el-form-item label="路线名称:" prop="name">
  5. <el-input
  6. v-model.trim="queryParams.name"
  7. placeholder="请输入路线名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item class="right">
  14. <el-button plain size="mini" @click="resetQuery">重置</el-button>
  15. <el-button type="primary" size="mini" @click="handleQuery">搜索</el-button>
  16. </el-form-item>
  17. <br>
  18. <el-button
  19. type="primary"
  20. size="mini"
  21. @click="handleAdd"
  22. >新增</el-button>
  23. </el-form>
  24. <el-table v-loading="loading" :data="adminList" style="margin-top:20px;" border>
  25. <el-table-column label="路线名称" align="center" prop="name" show-overflow-tooltip />
  26. <el-table-column label="创建时间" align="center" prop="createTime" show-overflow-tooltip />
  27. <el-table-column label="创建人" align="center" prop="createBy" show-overflow-tooltip />
  28. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
  29. <template slot-scope="scope">
  30. <el-button
  31. size="mini"
  32. class="lans"
  33. @click="handleUpdate(scope.row)"
  34. >修改</el-button>
  35. <el-button
  36. size="mini"
  37. class="lans"
  38. @click="handleDelete(scope.row)"
  39. >删除</el-button>
  40. </template>
  41. </el-table-column>
  42. </el-table>
  43. <!-- 修改、新增对话框 -->
  44. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body :before-close="cancel" :close-on-click-modal="false">
  45. <el-form ref="form" :model="form" :rules="rules" label-width="auto" >
  46. <el-row :gutter="20">
  47. <el-col :span="12">
  48. <el-form-item label="路线名称" prop="name">
  49. <el-input v-model="form.name" placeholder="请填写路线名称" @input="onInput()" maxlength="15" show-word-limit />
  50. </el-form-item>
  51. </el-col>
  52. <el-col style="font-size:16px;font-weight:700;margin:10px 0 20px;">维保点位</el-col>
  53. <el-table v-loading="loading2" :data="adminList2" height="200" @selection-change="handleSelectionChange" ref="dataTable" style="margin-bottom:50px">
  54. <el-table-column type="selection" />
  55. <el-table-column label="点位名称" align="center" prop="name" show-overflow-tooltip />
  56. <el-table-column label="点位地址" align="center" prop="address" show-overflow-tooltip />
  57. </el-table>
  58. <el-pagination
  59. style="bottom:0px"
  60. background
  61. @current-change="handleCurrentChange2"
  62. :page-sizes="[10, 15, 20, 30]"
  63. @size-change="handleSizeChange2"
  64. :current-page="queryParams2.pageNo"
  65. :page-size="queryParams2.pageSize"
  66. layout="sizes,prev, pager, next"
  67. :total="totalCount2"
  68. >
  69. </el-pagination>
  70. </el-row>
  71. </el-form>
  72. <div slot="footer" class="dialog-footer">
  73. <el-button type="primary" @click="submitForm">确 定</el-button>
  74. <el-button @click="cancel" plain>取 消</el-button>
  75. </div>
  76. </el-dialog>
  77. <el-pagination
  78. background
  79. @current-change="handleCurrentChange1"
  80. :page-sizes="[10, 15, 20, 30]"
  81. @size-change="handleSizeChange1"
  82. :current-page="queryParams.pageNo"
  83. :page-size="queryParams.pageSize"
  84. layout="sizes,prev, pager, next"
  85. :total="totalCount1"
  86. >
  87. </el-pagination>
  88. <a href="" download="" id="xz" style="position: absolute;z-index: -1;opacity: 0;"></a>
  89. </div>
  90. </template>
  91. <script>
  92. import { getInspectionPoint } from "@/api/MochaITOM/point";
  93. import { addPlanPath, delPlanPath, updatePlanPath, getPlanPath, getXL } from "@/api/MochaITOM/route";
  94. export default {
  95. name: "Floor",
  96. data() {
  97. return {
  98. loading:true,
  99. loading2:true,
  100. exportLoading:false,
  101. // 显示搜索条件
  102. showSearch: true,
  103. // 总条数
  104. totalCount1: undefined,
  105. // 总条数
  106. totalCount2: undefined,
  107. // 参数表格数据
  108. adminList: [],
  109. // 参数表格数据
  110. adminList2: [],
  111. // 弹出层标题
  112. title: "",
  113. // 是否显示弹出层
  114. open: false,
  115. // 查询参数
  116. queryParams: {
  117. current: 1,
  118. size: 15,
  119. name: undefined,
  120. dutyId:undefined,
  121. pageNo:1,
  122. pageSize:15,
  123. },
  124. // 查询参数
  125. queryParams2: {
  126. current: 1,
  127. size: 15,
  128. pageNo:1,
  129. pageSize:15,
  130. },
  131. // 表单参数
  132. form: {},
  133. // 表单校验
  134. rules: {
  135. name: [
  136. { required: true, message: "线路名称不能为空", trigger: "blur" }
  137. ],
  138. },
  139. tableHeight:undefined,
  140. };
  141. },
  142. created() {
  143. this.getList();//初始化table
  144. },
  145. mounted() {
  146. },
  147. methods: {
  148. //分页查询
  149. handleCurrentChange1(val) {
  150. this.queryParams.pageNo = val;
  151. this.getList();
  152. },
  153. //分页查询
  154. handleSizeChange1(val) {
  155. this.queryParams.pageSize = val;
  156. this.getList();
  157. },
  158. //分页查询
  159. handleCurrentChange2(val) {
  160. this.queryParams2.pageNo = val;
  161. this.getList();
  162. },
  163. //分页查询
  164. handleSizeChange2(val) {
  165. this.queryParams2.pageSize = val;
  166. this.getList();
  167. },
  168. //强制el-input刷新
  169. onInput(){
  170. this.$forceUpdate();
  171. },
  172. // 取消按钮
  173. cancel() {
  174. this.open = false;
  175. this.reset();
  176. },
  177. /** 重置按钮操作 */
  178. resetQuery() {
  179. this.queryParams = {
  180. name:undefined,
  181. current:1,
  182. size:15,
  183. pageSize:15,
  184. pageNo:1,
  185. }
  186. this.handleQuery();
  187. },
  188. // 表单重置
  189. reset() {
  190. this.form = {};
  191. // this.resetForm("form");
  192. },
  193. /** 搜索按钮操作 */
  194. handleQuery() {
  195. this.queryParams.current = 1;
  196. this.getList();
  197. },
  198. /** 查询参数列表 */
  199. getList() {
  200. this.loading = true;
  201. getPlanPath(this.queryParams).then(response => {
  202. this.adminList = response.data.pageList;
  203. this.totalCount1 = response.data.totalCount;
  204. this.loading = false;
  205. });
  206. },
  207. getList2(row){
  208. this.adminList2 = []
  209. getInspectionPoint(this.queryParams2).then(response => {
  210. this.adminList2 = response.data.pageList;
  211. this.totalCount2 = response.data.totalCount;
  212. if(row && row.pointIds.length>0){
  213. let list = []
  214. for(let a = 0;a<row.pointIds.length;a++){
  215. for(let i = 0; i<this.adminList2.length;i++){
  216. if(row.pointIds[a] == this.adminList2[i].id){
  217. list.push(this.adminList2[i])
  218. }
  219. }
  220. }
  221. setTimeout(() => {
  222. var that = this;
  223. that.$nextTick(() => {
  224. if(list){
  225. list.forEach((row) => {
  226. that.$refs.dataTable.toggleRowSelection(row, true)
  227. })
  228. }
  229. })
  230. this.total2 = response.data.total;
  231. this.loading2 = false;
  232. })
  233. }else{
  234. this.total2 = response.data.total;
  235. this.loading2 = false;
  236. }
  237. });
  238. },
  239. /** 修改按钮操作 */
  240. handleUpdate(row) {
  241. this.reset();
  242. this.title = "修改";
  243. this.form = JSON.parse(JSON.stringify(row))
  244. getXL({pathId:row.id}).then(res =>{
  245. if(res.data.length>0){
  246. row.pointIds = []
  247. for(let i=0;i<res.data.length;i++){
  248. row.pointIds.push(res.data[i].pointId)
  249. }
  250. }
  251. this.getList2(row)
  252. this.open = true;
  253. })
  254. },
  255. /** 新增按钮操作 */
  256. handleAdd() {
  257. this.reset();
  258. this.getList2()
  259. this.open = true;
  260. this.title = "新增";
  261. },
  262. /** 提交按钮 */
  263. submitForm(row) {
  264. this.form.userIds = []
  265. this.form.userIds = this.list
  266. this.$refs["form"].validate(valid => {
  267. if (valid) {
  268. this.loading = true
  269. if (this.form.id != undefined) {
  270. updatePlanPath(this.form).then(response => {
  271. this.loading = false,
  272. this.$message.success("修改成功");
  273. this.open = false;
  274. this.getList();
  275. }).catch(()=>{
  276. this.loading = false
  277. })
  278. } else {
  279. addPlanPath(this.form).then(response => {
  280. this.loading = false
  281. if(response.status == "SUCCESS"){
  282. this.$message.success("新增成功");
  283. this.open = false;
  284. this.getList();
  285. }
  286. })
  287. }
  288. }
  289. });
  290. },
  291. /** 删除按钮操作 */
  292. handleDelete(row) {
  293. const ids = row.id || this.ids;
  294. this.$confirm('是否确认删除', "警告", {
  295. confirmButtonText: "确定",
  296. cancelButtonText: "取消",
  297. type: "warning"
  298. }).then(function() {
  299. return delPlanPath(ids);
  300. }).then(() => {
  301. this.getList();
  302. this.$message.success("删除成功");
  303. }).catch(() => {});
  304. },
  305. /** table */
  306. handleSelectionChange(row){
  307. this.form.pointIds = []
  308. for(let i=0;i<row.length;i++){
  309. this.form.pointIds.push(row[i].id)
  310. }
  311. }
  312. }
  313. };
  314. </script>