index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item>
  5. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">{{ $t('搜索') }}</el-button>
  6. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
  7. </el-form-item>
  8. </el-form>
  9. <el-row :gutter="10" class="mb8">
  10. <el-col :span="1.5">
  11. <el-button
  12. type="primary"
  13. icon="el-icon-plus"
  14. size="mini"
  15. @click="handleAdd"
  16. v-hasPermi="['ehs:rcauditmenu:add']"
  17. >{{ $t('新增') }}</el-button>
  18. </el-col>
  19. <el-col :span="1.5">
  20. <el-button
  21. type="success"
  22. icon="el-icon-edit"
  23. size="mini"
  24. :disabled="single"
  25. @click="handleUpdate"
  26. v-hasPermi="['ehs:rcauditmenu:edit']"
  27. >{{ $t('修改') }}</el-button>
  28. </el-col>
  29. <el-col :span="1.5">
  30. <el-button
  31. type="danger"
  32. icon="el-icon-delete"
  33. size="mini"
  34. :disabled="multiple"
  35. @click="handleDelete"
  36. v-hasPermi="['ehs:rcauditmenu:remove']"
  37. >{{ $t('删除') }}</el-button>
  38. </el-col>
  39. <el-col :span="1.5">
  40. <el-button
  41. type="info"
  42. icon="el-icon-upload2"
  43. size="mini"
  44. @click="handleImport"
  45. v-hasPermi="['ehs:rcauditmenu:edit']"
  46. >{{ $t('导入') }}</el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button
  50. type="warning"
  51. icon="el-icon-download"
  52. size="mini"
  53. @click="handleExport"
  54. v-hasPermi="['ehs:rcauditmenu:export']"
  55. >{{ $t('导出') }}</el-button>
  56. </el-col>
  57. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  58. </el-row>
  59. <el-table v-loading="loading" :data="rcauditmenuList" @selection-change="handleSelectionChange" :height="clientHeight" border>
  60. <el-table-column type="selection" width="55" align="center" />
  61. <el-table-column :label="$t('装置名称')" align="center" prop="plantCode" :formatter="plantCodeFormat" />
  62. <el-table-column :label="$t('RC代码')" align="center" prop="serialNum" :show-overflow-tooltip="true"/>
  63. <el-table-column :label="$t('名称')" align="center" prop="nameCn" :show-overflow-tooltip="true"/>
  64. <el-table-column :label="$t('英文名称')" align="center" prop="nameEn" :show-overflow-tooltip="true"/>
  65. <el-table-column :label="$t('操作')" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  66. <template slot-scope="scope">
  67. <el-button
  68. size="mini"
  69. type="text"
  70. icon="el-icon-edit"
  71. @click="handleUpdate(scope.row)"
  72. v-hasPermi="['ehs:rcauditmenu:edit']"
  73. >{{ $t('修改') }}</el-button>
  74. <el-button
  75. size="mini"
  76. type="text"
  77. icon="el-icon-delete"
  78. @click="handleDelete(scope.row)"
  79. v-hasPermi="['ehs:rcauditmenu:remove']"
  80. >{{ $t('删除') }}</el-button>
  81. </template>
  82. </el-table-column>
  83. </el-table>
  84. <pagination
  85. v-show="total>0"
  86. :total="total"
  87. :page.sync="queryParams.pageNum"
  88. :limit.sync="queryParams.pageSize"
  89. @pagination="getList"
  90. />
  91. <!-- 添加或修改RC审计助手目录对话框 -->
  92. <el-dialog v-dialogDrag :title="title" :visible.sync="open" width="500px" append-to-body>
  93. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  94. <el-form-item :label="$t('装置名称')" prop="plantCode">
  95. <el-select v-model="form.plantCode" :placeholder="$t('请选择') + $t('装置名称')">
  96. <el-option
  97. v-for="dict in plantCodeOptions"
  98. :key="dict.dictValue"
  99. :label="dict.dictLabel"
  100. :value="dict.dictValue"
  101. ></el-option>
  102. </el-select>
  103. </el-form-item>
  104. <el-form-item :label="$t('RC代码')" prop="serialNum">
  105. <el-input v-model="form.serialNum" :placeholder="$t('请输入') + $t('RC代码')" />
  106. </el-form-item>
  107. <el-form-item :label="$t('名称')" prop="nameCn">
  108. <el-input v-model="form.nameCn" :placeholder="$t('请输入') + $t('名称')" />
  109. </el-form-item>
  110. <el-form-item :label="$t('英文名称')" prop="nameEn">
  111. <el-input v-model="form.nameEn" :placeholder="$t('请输入') + $t('英文名称')" />
  112. </el-form-item>
  113. <el-form-item :label="$t('备注')" prop="remarks">
  114. <el-input v-model="form.remarks" :placeholder="$t('请输入') + $t('备注')" />
  115. </el-form-item>
  116. <el-form-item :label="$t('归属部门')" prop="deptId">
  117. <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" :placeholder="$t('请选择') + $t('归属部门')" />
  118. </el-form-item>
  119. </el-form>
  120. <div slot="footer" class="dialog-footer">
  121. <el-button type="primary" @click="submitForm">{{ $t('确 定') }}</el-button>
  122. <el-button @click="cancel">{{ $t('取 消') }}</el-button>
  123. </div>
  124. </el-dialog>
  125. <!-- 用户导入对话框 -->
  126. <el-dialog v-dialogDrag :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  127. <el-upload
  128. ref="upload"
  129. :limit="1"
  130. accept=".xlsx, .xls"
  131. :headers="upload.headers"
  132. :action="upload.url"
  133. :disabled="upload.isUploading"
  134. :on-progress="handleFileUploadProgress"
  135. :on-success="handleFileSuccess"
  136. :auto-upload="false"
  137. drag
  138. >
  139. <i class="el-icon-upload"></i>
  140. <div class="el-upload__text">
  141. {{ $t('将文件拖到此处,或') }}
  142. <em>{{ $t('点击上传') }}</em>
  143. </div>
  144. <div class="el-upload__tip" slot="tip">
  145. <!--<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
  146. <el-link type="info" style="font-size:12px" @click="importTemplate">{{ $t('下载模板') }}</el-link>
  147. </div>
  148. <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
  149. <input name="type" :value="upload.type" hidden />
  150. </form>
  151. <div class="el-upload__tip" style="color:red" slot="tip">{{ $t('提示:仅允许导入“xls”或“xlsx”格式文件!') }}</div>
  152. </el-upload>
  153. <div slot="footer" class="dialog-footer">
  154. <el-button type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button>
  155. <el-button @click="upload.open = false">{{ $t('取 消') }}</el-button>
  156. </div>
  157. </el-dialog>
  158. </div>
  159. </template>
  160. <script>
  161. import { listRcauditmenu, getRcauditmenu, delRcauditmenu, addRcauditmenu, updateRcauditmenu, exportRcauditmenu } from "@/api/ehs/rcauditmenu";
  162. import { treeselect } from "@/api/system/dept";
  163. import { getToken } from "@/utils/auth";
  164. import Treeselect from "@riophae/vue-treeselect";
  165. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  166. export default {
  167. name: "Rcauditmenu",
  168. components: { Treeselect },
  169. data() {
  170. return {
  171. // 遮罩层
  172. loading: true,
  173. // 选中数组
  174. ids: [],
  175. // 非单个禁用
  176. single: true,
  177. // 非多个禁用
  178. multiple: true,
  179. // 显示搜索条件
  180. showSearch: false,
  181. // 总条数
  182. total: 0,
  183. // RC审计助手目录表格数据
  184. rcauditmenuList: [],
  185. // 弹出层标题
  186. title: "",
  187. // 部门树选项
  188. deptOptions: undefined,
  189. clientHeight:300,
  190. // 是否显示弹出层
  191. open: false,
  192. // 装置名称字典
  193. plantCodeOptions: [],
  194. // 用户导入参数
  195. upload: {
  196. //下载模板请求地址
  197. downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
  198. //下载模板类型
  199. type: "rcauditmenu",
  200. // 是否显示弹出层(用户导入)
  201. open: false,
  202. // 弹出层标题(用户导入)
  203. title: "",
  204. // 是否禁用上传
  205. isUploading: false,
  206. // 是否更新已经存在的用户数据
  207. updateSupport: 0,
  208. // 设置上传的请求头部
  209. headers: { Authorization: "Bearer " + getToken() },
  210. // 上传的地址
  211. url: process.env.VUE_APP_BASE_API + "/ehs/rcauditmenu/importData"
  212. },
  213. // 查询参数
  214. queryParams: {
  215. pageNum: 1,
  216. pageSize: 20,
  217. },
  218. // 表单参数
  219. form: {},
  220. // 表单校验
  221. rules: {
  222. plantCode: [
  223. { required: true, message: this.$t('装置名称') + this.$t('不能为空'), trigger: "change" }
  224. ],
  225. serialNum: [
  226. { required: true, message: this.$t('RC代码') + this.$t('不能为空'), trigger: "blur" }
  227. ],
  228. nameCn: [
  229. { required: true, message: this.$t('名称') + this.$t('不能为空'), trigger: "blur" }
  230. ],
  231. deptId: [
  232. { required: true, message: this.$t('部门编号') + this.$t('不能为空'), trigger: "blur" }
  233. ],
  234. }
  235. };
  236. },
  237. watch: {
  238. // 根据名称筛选部门树
  239. deptName(val) {
  240. this.$refs.tree.filter(val);
  241. }
  242. },
  243. created() {
  244. //设置表格高度对应屏幕高度
  245. this.$nextTick(() => {
  246. this.clientHeight = (document.body.clientHeight - 80) * 0.8
  247. })
  248. this.getList();
  249. this.getTreeselect();
  250. this.getDicts("PLANT_DIVIDE").then(response => {
  251. this.plantCodeOptions = response.data;
  252. });
  253. },
  254. methods: {
  255. /** 查询RC审计助手目录列表 */
  256. getList() {
  257. this.loading = true;
  258. listRcauditmenu(this.queryParams).then(response => {
  259. this.rcauditmenuList = response.rows;
  260. this.total = response.total;
  261. this.loading = false;
  262. });
  263. },
  264. /** 查询部门下拉树结构 */
  265. getTreeselect() {
  266. treeselect().then(response => {
  267. this.deptOptions = response.data;
  268. });
  269. },
  270. // 装置名称字典翻译
  271. plantCodeFormat(row, column) {
  272. return this.selectDictLabel(this.plantCodeOptions, row.plantCode);
  273. },
  274. // 取消按钮
  275. cancel() {
  276. this.open = false;
  277. this.reset();
  278. },
  279. // 表单重置
  280. reset() {
  281. this.form = {
  282. id: null,
  283. plantCode: null,
  284. serialNum: null,
  285. nameCn: null,
  286. nameEn: null,
  287. deptId: null,
  288. delFlag: null,
  289. createrCode: null,
  290. createdate: null,
  291. updaterCode: null,
  292. updatedate: null,
  293. remarks: null
  294. };
  295. this.resetForm("form");
  296. },
  297. /** 搜索按钮操作 */
  298. handleQuery() {
  299. this.queryParams.pageNum = 1;
  300. this.getList();
  301. },
  302. /** 重置按钮操作 */
  303. resetQuery() {
  304. this.resetForm("queryForm");
  305. this.handleQuery();
  306. },
  307. // 多选框选中数据
  308. handleSelectionChange(selection) {
  309. this.ids = selection.map(item => item.id)
  310. this.single = selection.length!==1
  311. this.multiple = !selection.length
  312. },
  313. /** 新增按钮操作 */
  314. handleAdd() {
  315. this.reset();
  316. this.open = true;
  317. this.title = this.$t('新增') + " " + this.$t('RC审计助手目录');
  318. },
  319. /** 修改按钮操作 */
  320. handleUpdate(row) {
  321. this.reset();
  322. const id = row.id || this.ids
  323. getRcauditmenu(id).then(response => {
  324. this.form = response.data;
  325. this.open = true;
  326. this.title = this.$t('修改') + this.$t('RC审计助手目录');
  327. });
  328. },
  329. /** 提交按钮 */
  330. submitForm() {
  331. this.$refs["form"].validate(valid => {
  332. if (valid) {
  333. if (this.form.id != null) {
  334. updateRcauditmenu(this.form).then(response => {
  335. this.msgSuccess(this.$t('修改成功'));
  336. this.open = false;
  337. this.getList();
  338. });
  339. } else {
  340. addRcauditmenu(this.form).then(response => {
  341. this.msgSuccess(this.$t('新增成功'));
  342. this.open = false;
  343. this.getList();
  344. });
  345. }
  346. }
  347. });
  348. },
  349. /** 删除按钮操作 */
  350. handleDelete(row) {
  351. const ids = row.id || this.ids;
  352. this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
  353. confirmButtonText: this.$t('确定'),
  354. cancelButtonText: this.$t('取消'),
  355. type: "warning"
  356. }).then(function() {
  357. return delRcauditmenu(ids);
  358. }).then(() => {
  359. this.getList();
  360. this.msgSuccess(this.$t('删除成功'));
  361. })
  362. },
  363. /** 导出按钮操作 */
  364. handleExport() {
  365. const queryParams = this.queryParams;
  366. this.$confirm(this.$t('是否确认导出所有RC审计助手目录数据项?'), this.$t('警告'), {
  367. confirmButtonText: this.$t('确定'),
  368. cancelButtonText: this.$t('取消'),
  369. type: "warning"
  370. }).then(function() {
  371. return exportRcauditmenu(queryParams);
  372. }).then(response => {
  373. this.download(response.msg);
  374. })
  375. },
  376. /** 导入按钮操作 */
  377. handleImport() {
  378. this.upload.title = this.$t('用户导入');
  379. this.upload.open = true;
  380. },
  381. /** 下载模板操作 */
  382. importTemplate() {
  383. this.$refs['downloadFileForm'].submit()
  384. },
  385. // 文件上传中处理
  386. handleFileUploadProgress(event, file, fileList) {
  387. this.upload.isUploading = true;
  388. },
  389. // 文件上传成功处理
  390. handleFileSuccess(response, file, fileList) {
  391. this.upload.open = false;
  392. this.upload.isUploading = false;
  393. this.$refs.upload.clearFiles();
  394. if (response.data[0] != null) {
  395. this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据') + "," + this.$t('第') + response.data + this.$t('行数据出现错误导入失败')+"。", this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  396. }else {
  397. this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据'), this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  398. }
  399. this.getList();
  400. },
  401. // 提交上传文件
  402. submitFileForm() {
  403. this.$refs.upload.submit();
  404. }
  405. }
  406. };
  407. </script>