index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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="busEnterpriseId">
  5. <el-input
  6. v-model="queryParams.busEnterpriseId"
  7. placeholder="请输入企业ID"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="巡检项ID" prop="busItemsId">
  13. <el-input
  14. v-model="queryParams.busItemsId"
  15. placeholder="请输入巡检项ID"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  22. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <el-row :gutter="10" class="mb8">
  26. <el-col :span="1.5">
  27. <el-button
  28. type="primary"
  29. plain
  30. icon="el-icon-plus"
  31. size="mini"
  32. @click="handleAdd"
  33. v-hasPermi="['system:mapping:add']"
  34. >新增</el-button>
  35. </el-col>
  36. <el-col :span="1.5">
  37. <el-button
  38. type="success"
  39. plain
  40. icon="el-icon-edit"
  41. size="mini"
  42. :disabled="single"
  43. @click="handleUpdate"
  44. v-hasPermi="['system:mapping:edit']"
  45. >修改</el-button>
  46. </el-col>
  47. <el-col :span="1.5">
  48. <el-button
  49. type="danger"
  50. plain
  51. icon="el-icon-delete"
  52. size="mini"
  53. :disabled="multiple"
  54. @click="handleDelete"
  55. v-hasPermi="['system:mapping:remove']"
  56. >删除</el-button>
  57. </el-col>
  58. <el-col :span="1.5">
  59. <el-button
  60. type="warning"
  61. plain
  62. icon="el-icon-download"
  63. size="mini"
  64. @click="handleExport"
  65. v-hasPermi="['system:mapping:export']"
  66. >导出</el-button>
  67. </el-col>
  68. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  69. </el-row>
  70. <el-table v-loading="loading" :data="mappingList" @selection-change="handleSelectionChange">
  71. <el-table-column type="selection" width="55" align="center" />
  72. <el-table-column label="企业ID" align="center" prop="busEnterpriseId" />
  73. <el-table-column label="巡检项ID" align="center" prop="busItemsId" />
  74. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  75. <template slot-scope="scope">
  76. <el-button
  77. size="mini"
  78. type="text"
  79. icon="el-icon-edit"
  80. @click="handleUpdate(scope.row)"
  81. v-hasPermi="['system:mapping:edit']"
  82. >修改</el-button>
  83. <el-button
  84. size="mini"
  85. type="text"
  86. icon="el-icon-delete"
  87. @click="handleDelete(scope.row)"
  88. v-hasPermi="['system:mapping:remove']"
  89. >删除</el-button>
  90. </template>
  91. </el-table-column>
  92. </el-table>
  93. <pagination
  94. v-show="total>0"
  95. :total="total"
  96. :page.sync="queryParams.pageNum"
  97. :limit.sync="queryParams.pageSize"
  98. @pagination="getList"
  99. />
  100. <!-- 添加或修改企业与巡检项映射对话框 -->
  101. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  102. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  103. <el-form-item label="企业ID" prop="busEnterpriseId">
  104. <el-input v-model="form.busEnterpriseId" placeholder="请输入企业ID" />
  105. </el-form-item>
  106. <el-form-item label="巡检项ID" prop="busItemsId">
  107. <el-input v-model="form.busItemsId" placeholder="请输入巡检项ID" />
  108. </el-form-item>
  109. </el-form>
  110. <div slot="footer" class="dialog-footer">
  111. <el-button type="primary" @click="submitForm">确 定</el-button>
  112. <el-button @click="cancel">取 消</el-button>
  113. </div>
  114. </el-dialog>
  115. </div>
  116. </template>
  117. <script>
  118. import { listMapping, getMapping, delMapping, addMapping, updateMapping } from "@/api/edyj/mapping";
  119. export default {
  120. name: "Mapping",
  121. data() {
  122. return {
  123. // 遮罩层
  124. loading: true,
  125. // 选中数组
  126. ids: [],
  127. // 非单个禁用
  128. single: true,
  129. // 非多个禁用
  130. multiple: true,
  131. // 显示搜索条件
  132. showSearch: true,
  133. // 总条数
  134. total: 0,
  135. // 企业与巡检项映射表格数据
  136. mappingList: [],
  137. // 弹出层标题
  138. title: "",
  139. // 是否显示弹出层
  140. open: false,
  141. // 查询参数
  142. queryParams: {
  143. pageNum: 1,
  144. pageSize: 10,
  145. busEnterpriseId: null,
  146. busItemsId: null
  147. },
  148. // 表单参数
  149. form: {},
  150. // 表单校验
  151. rules: {
  152. }
  153. };
  154. },
  155. created() {
  156. this.getList();
  157. },
  158. methods: {
  159. /** 查询企业与巡检项映射列表 */
  160. getList() {
  161. this.loading = true;
  162. listMapping(this.queryParams).then(response => {
  163. this.mappingList = response.rows;
  164. this.total = response.total;
  165. this.loading = false;
  166. });
  167. },
  168. // 取消按钮
  169. cancel() {
  170. this.open = false;
  171. this.reset();
  172. },
  173. // 表单重置
  174. reset() {
  175. this.form = {
  176. busEnterpriseId: null,
  177. busItemsId: null
  178. };
  179. this.resetForm("form");
  180. },
  181. /** 搜索按钮操作 */
  182. handleQuery() {
  183. this.queryParams.pageNum = 1;
  184. this.getList();
  185. },
  186. /** 重置按钮操作 */
  187. resetQuery() {
  188. this.resetForm("queryForm");
  189. this.handleQuery();
  190. },
  191. // 多选框选中数据
  192. handleSelectionChange(selection) {
  193. this.ids = selection.map(item => item.busEnterpriseId)
  194. this.single = selection.length!==1
  195. this.multiple = !selection.length
  196. },
  197. /** 新增按钮操作 */
  198. handleAdd() {
  199. this.reset();
  200. this.open = true;
  201. this.title = "添加企业与巡检项映射";
  202. },
  203. /** 修改按钮操作 */
  204. handleUpdate(row) {
  205. this.reset();
  206. const busEnterpriseId = row.busEnterpriseId || this.ids
  207. getMapping(busEnterpriseId).then(response => {
  208. this.form = response.data;
  209. this.open = true;
  210. this.title = "修改企业与巡检项映射";
  211. });
  212. },
  213. /** 提交按钮 */
  214. submitForm() {
  215. this.$refs["form"].validate(valid => {
  216. if (valid) {
  217. if (this.form.busEnterpriseId != null) {
  218. updateMapping(this.form).then(response => {
  219. this.$modal.msgSuccess("修改成功");
  220. this.open = false;
  221. this.getList();
  222. });
  223. } else {
  224. addMapping(this.form).then(response => {
  225. this.$modal.msgSuccess("新增成功");
  226. this.open = false;
  227. this.getList();
  228. });
  229. }
  230. }
  231. });
  232. },
  233. /** 删除按钮操作 */
  234. handleDelete(row) {
  235. const busEnterpriseIds = row.busEnterpriseId || this.ids;
  236. this.$modal.confirm('是否确认删除企业与巡检项映射编号为"' + busEnterpriseIds + '"的数据项?').then(function() {
  237. return delMapping(busEnterpriseIds);
  238. }).then(() => {
  239. this.getList();
  240. this.$modal.msgSuccess("删除成功");
  241. }).catch(() => {});
  242. },
  243. /** 导出按钮操作 */
  244. handleExport() {
  245. this.download('system/mapping/export', {
  246. ...this.queryParams
  247. }, `mapping_${new Date().getTime()}.xlsx`)
  248. }
  249. }
  250. };
  251. </script>