riskreminder.vue 14 KB

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