index.vue 10 KB

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