index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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" height="calc(100vh - 28vh)">
  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="300" @selection-change="handleSelectionChange" ref="dataTable">
  61. <el-table-column type="selection" />
  62. <el-table-column label="点位名称" align="center" prop="spotName" show-overflow-tooltip />
  63. <el-table-column label="点位地址" align="center" prop="spotAddress" show-overflow-tooltip />
  64. <el-table-column label="点位图片" align="center" prop="pictureRoute" show-overflow-tooltip >
  65. <template slot-scope="scope">
  66. <el-image
  67. v-if="scope.row.pictureRoute"
  68. style="width: 24px; height: 24px"
  69. :preview-src-list="['https://smartpark.caih.com/dmapi/archive/' + scope.row.pictureRoute]"
  70. :src="'https://smartpark.caih.com/dmapi/archive/' + scope.row.pictureRoute">
  71. </el-image>
  72.   </template>
  73. </el-table-column>
  74. </el-table>
  75. <pagination
  76. v-show="total2>0"
  77. :total="total2"
  78. :page.sync="queryParams2.current"
  79. :limit.sync="queryParams2.size"
  80. @pagination="getList2"
  81. />
  82. </el-row>
  83. </el-form>
  84. <div slot="footer" class="dialog-footer">
  85. <el-button type="primary" @click="submitForm">确 定</el-button>
  86. <el-button @click="cancel">取 消</el-button>
  87. </div>
  88. </el-dialog>
  89. <pagination
  90. v-show="total>0"
  91. :total="total"
  92. :page.sync="queryParams.current"
  93. :limit.sync="queryParams.size"
  94. @pagination="getList"
  95. />
  96. <a href="" download="" id="xz" style="position: absolute;z-index: -1;opacity: 0;"></a>
  97. </div>
  98. </template>
  99. <script>
  100. import { getInspectionPoint } from "@/api/MochaITOM/point";
  101. import { addPlanPath, delPlanPath, updatePlanPath, getPlanPath, getXL } from "@/api/MochaITOM/route";
  102. export default {
  103. name: "Floor",
  104. data() {
  105. return {
  106. loading:true,
  107. loading2:true,
  108. exportLoading:false,
  109. // 显示搜索条件
  110. showSearch: true,
  111. // 总条数
  112. total: 0,
  113. // 总条数
  114. total2: 0,
  115. // 参数表格数据
  116. adminList: [],
  117. // 参数表格数据
  118. adminList2: [],
  119. // 弹出层标题
  120. title: "",
  121. // 是否显示弹出层
  122. open: false,
  123. // 查询参数
  124. queryParams: {
  125. current: 1,
  126. size: 20,
  127. name: undefined,
  128. dutyId:undefined
  129. },
  130. // 查询参数
  131. queryParams2: {
  132. current: 1,
  133. size: 20,
  134. },
  135. // 表单参数
  136. form: {},
  137. // 表单校验
  138. rules: {
  139. name: [
  140. { required: true, message: "线路名称不能为空", trigger: "blur" }
  141. ],
  142. },
  143. };
  144. },
  145. created() {
  146. this.getList();//初始化table
  147. },
  148. methods: {
  149. //强制el-input刷新
  150. onInput(){
  151. this.$forceUpdate();
  152. },
  153. // 取消按钮
  154. cancel() {
  155. this.open = false;
  156. this.reset();
  157. },
  158. /** 重置按钮操作 */
  159. resetQuery() {
  160. this.dateRange = [];
  161. this.queryParams = {
  162. name:undefined,
  163. current:1,
  164. size:20
  165. }
  166. this.resetForm("queryForm");
  167. this.handleQuery();
  168. },
  169. // 表单重置
  170. reset() {
  171. this.form = {};
  172. this.resetForm("form");
  173. },
  174. /** 搜索按钮操作 */
  175. handleQuery() {
  176. this.queryParams.current = 1;
  177. this.getList();
  178. },
  179. /** 查询参数列表 */
  180. getList() {
  181. this.loading = true;
  182. getPlanPath(this.queryParams).then(response => {
  183. this.adminList = response.data.records;
  184. this.total = response.data.total;
  185. this.loading = false;
  186. });
  187. },
  188. getList2(row){
  189. this.adminList2 = []
  190. getInspectionPoint(this.queryParams2).then(response => {
  191. this.adminList2 = response.data.records;
  192. if(row && row.pointIds.length>0){
  193. let list = []
  194. for(let a = 0;a<row.pointIds.length;a++){
  195. for(let i = 0; i<this.adminList2.length;i++){
  196. if(row.pointIds[a] == this.adminList2[i].id){
  197. list.push(this.adminList2[i])
  198. }
  199. }
  200. }
  201. setTimeout(() => {
  202. var that = this;
  203. that.$nextTick(() => {
  204. if(list){
  205. list.forEach((row) => {
  206. that.$refs.dataTable.toggleRowSelection(row, true)
  207. })
  208. }
  209. })
  210. this.total2 = response.data.total;
  211. this.loading2 = false;
  212. })
  213. }else{
  214. this.total2 = response.data.total;
  215. this.loading2 = false;
  216. }
  217. });
  218. },
  219. /** 修改按钮操作 */
  220. handleUpdate(row) {
  221. this.reset();
  222. this.title = "修改";
  223. this.form = JSON.parse(JSON.stringify(row))
  224. getXL({pathId:row.id}).then(res =>{
  225. if(res.data.length>0){
  226. row.pointIds = []
  227. for(let i=0;i<res.data.length;i++){
  228. row.pointIds.push(res.data[i].spotId)
  229. }
  230. }
  231. this.getList2(row)
  232. this.open = true;
  233. })
  234. },
  235. /** 新增按钮操作 */
  236. handleAdd() {
  237. this.reset();
  238. this.getList2()
  239. this.open = true;
  240. this.title = "新增";
  241. },
  242. /** 提交按钮 */
  243. submitForm(row) {
  244. this.form.userIds = []
  245. this.form.userIds = this.list
  246. this.$refs["form"].validate(valid => {
  247. if (valid) {
  248. this.loading = true
  249. if (this.form.id != undefined) {
  250. updatePlanPath(this.form).then(response => {
  251. this.loading = false,
  252. this.msgSuccess("修改成功");
  253. this.open = false;
  254. this.getList();
  255. }).catch(()=>{
  256. this.loading = false
  257. })
  258. } else {
  259. addPlanPath(this.form).then(response => {
  260. this.loading = false,
  261. this.msgSuccess("新增成功");
  262. this.open = false;
  263. this.getList();
  264. }).catch(()=>{
  265. this.loading = false
  266. })
  267. }
  268. }
  269. });
  270. },
  271. /** 删除按钮操作 */
  272. handleDelete(row) {
  273. const ids = row.id || this.ids;
  274. this.$confirm('是否确认删除', "警告", {
  275. confirmButtonText: "确定",
  276. cancelButtonText: "取消",
  277. type: "warning"
  278. }).then(function() {
  279. return delPlanPath(ids);
  280. }).then(() => {
  281. this.getList();
  282. this.msgSuccess("删除成功");
  283. }).catch(() => {});
  284. },
  285. /** table */
  286. handleSelectionChange(row){
  287. this.form.pointIds = []
  288. for(let i=0;i<row.length;i++){
  289. this.form.pointIds.push(row[i].id)
  290. }
  291. }
  292. }
  293. };
  294. </script>