index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  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="装置" prop="deptId">
  5. <el-select clearable v-model="queryParams.deptId" placeholder="请选择装置">
  6. <el-option
  7. v-for="dict in deptOptions"
  8. :key="dict.dictValue"
  9. :label="dict.dictLabel"
  10. :value="dict.dictValue"
  11. ></el-option>
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="年份" prop="year">
  15. <el-date-picker clearable
  16. v-model="queryParams.year"
  17. type="year"
  18. value-format="yyyy"
  19. placeholder="请选择年份">
  20. </el-date-picker>
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  24. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</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. plain
  32. icon="el-icon-plus"
  33. size="mini"
  34. @click="handleAdd"
  35. v-hasPermi="['rc:deptinfo:add']"
  36. >新增</el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button
  40. type="success"
  41. plain
  42. icon="el-icon-edit"
  43. size="mini"
  44. :disabled="single"
  45. @click="handleUpdate"
  46. v-hasPermi="['rc:deptinfo:edit']"
  47. >修改</el-button>
  48. </el-col>
  49. <el-col :span="1.5">
  50. <el-button
  51. type="danger"
  52. plain
  53. icon="el-icon-delete"
  54. size="mini"
  55. :disabled="multiple"
  56. @click="handleDelete"
  57. v-hasPermi="['rc:deptinfo:remove']"
  58. >删除</el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="warning"
  63. plain
  64. icon="el-icon-download"
  65. size="mini"
  66. @click="handleExport"
  67. v-hasPermi="['rc:deptinfo:export']"
  68. >导出</el-button>
  69. </el-col>
  70. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  71. </el-row>
  72. <el-table border v-loading="loading" :data="deptinfoList" @selection-change="handleSelectionChange">
  73. <el-table-column type="selection" width="55" align="center" />
  74. <el-table-column label="装置" align="center" prop="deptName" width="120"/>
  75. <el-table-column label="年份" align="center" prop="year" width="120">
  76. <template slot-scope="scope">
  77. <span>{{ parseTime(scope.row.year, '{y}') }}</span>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="装置信息" align="center" prop="deptInfo" />
  81. <el-table-column label="装置平面图" align="center" width="120" fixed="right">
  82. <template slot-scope="scope">
  83. <el-button icon="el-icon-folder" style="color:#6e96fa;" circle @click="handleDoc(scope.row , 'deptinfo-plane')"></el-button>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="装置欢迎介绍" align="center" width="120" fixed="right">
  87. <template slot-scope="scope">
  88. <el-button icon="el-icon-folder" style="color:#6e96fa;" circle @click="handleDoc(scope.row , 'deptinfo-welcome')"></el-button>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="装置视频介绍" align="center" width="120" fixed="right">
  92. <template slot-scope="scope">
  93. <el-button icon="el-icon-folder" style="color:#6e96fa;" circle @click="handleDoc(scope.row , 'deptinfo-video')"></el-button>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="操作" align="center" width="120" fixed="right" class-name="small-padding fixed-width">
  97. <template slot-scope="scope">
  98. <el-button
  99. size="mini"
  100. type="text"
  101. icon="el-icon-edit"
  102. @click="handleUpdate(scope.row)"
  103. v-hasPermi="['rc:deptinfo:edit']"
  104. >修改</el-button>
  105. <el-button
  106. size="mini"
  107. type="text"
  108. icon="el-icon-delete"
  109. @click="handleDelete(scope.row)"
  110. v-hasPermi="['rc:deptinfo:remove']"
  111. >删除</el-button>
  112. </template>
  113. </el-table-column>
  114. </el-table>
  115. <pagination
  116. v-show="total>0"
  117. :total="total"
  118. :page.sync="queryParams.pageNum"
  119. :limit.sync="queryParams.pageSize"
  120. @pagination="getList"
  121. />
  122. <!-- 添加或修改装置信息对话框 -->
  123. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  124. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  125. <el-form-item label="装置" prop="deptId">
  126. <el-select clearable v-model="form.deptId" placeholder="请选择装置">
  127. <el-option
  128. v-for="dict in deptOptions"
  129. :key="dict.dictValue"
  130. :label="dict.dictLabel"
  131. :value="dict.dictValue"
  132. ></el-option>
  133. </el-select>
  134. </el-form-item>
  135. <el-form-item label="年份" prop="year">
  136. <el-date-picker clearable
  137. v-model="form.year"
  138. type="year"
  139. value-format="yyyy"
  140. placeholder="请选择年份">
  141. </el-date-picker>
  142. </el-form-item>
  143. <el-form-item label="装置信息" prop="deptInfo">
  144. <el-input v-model="form.deptInfo" type="textarea" placeholder="请输入内容" />
  145. </el-form-item>
  146. </el-form>
  147. <div slot="footer" class="dialog-footer">
  148. <el-button type="primary" @click="submitForm">确 定</el-button>
  149. <el-button @click="cancel">取 消</el-button>
  150. </div>
  151. </el-dialog>
  152. <!-- 附件对话框 -->
  153. <el-dialog :close-on-click-modal="false" v-dialogDrag :title="doc.title" :visible.sync="doc.open" width="800px" append-to-body >
  154. <el-upload ref="doc"
  155. :limit="50"
  156. :headers="doc.headers"
  157. :action="doc.url + '?pType=' + doc.pType + '&pId=' + doc.pId"
  158. :disabled="doc.isUploading"
  159. :on-progress="handleFileDocProgress"
  160. :on-success="handleFileDocSuccess"
  161. :auto-upload="true"
  162. drag
  163. >
  164. <i class="el-icon-upload"></i>
  165. <div class="el-upload__text">
  166. 将文件拖到此处,或
  167. <em>点击上传</em>
  168. </div>
  169. </el-upload>
  170. <el-table :data="doc.commonfileList" border>
  171. <el-table-column label="文件名" align="center" prop="fileName" :show-overflow-tooltip="true">
  172. <template slot-scope="scope">
  173. <a class="link-type" @click="handleDownload(scope.row)">
  174. <span>{{ scope.row.fileName }}</span>
  175. </a>
  176. </template>
  177. </el-table-column>
  178. <el-table-column label="大小(Kb)" align="center" prop="fileSize" :show-overflow-tooltip="true" width="80" />
  179. <el-table-column label="上传人" align="center" prop="creator" :show-overflow-tooltip="true" width="120"/>
  180. <el-table-column label="操作" align="center" width="220" class-name="small-padding fixed-width">
  181. <template slot-scope="scope">
  182. <el-button
  183. size="mini"
  184. type="text"
  185. icon="el-icon-download"
  186. @click="handleDownload(scope.row)"
  187. >下载</el-button>
  188. <el-button
  189. size="mini"
  190. type="text"
  191. icon="el-icon-delete"
  192. @click="handleDeleteDoc(scope.row)"
  193. >删除</el-button>
  194. </template>
  195. </el-table-column>
  196. </el-table>
  197. </el-dialog>
  198. </div>
  199. </template>
  200. <script>
  201. import { listDeptinfo, getDeptinfo, delDeptinfo, addDeptinfo, updateDeptinfo } from "@/api/rc/deptinfo";
  202. import { listDept } from "@/api/system/dept";
  203. import { getUserDeptId } from "@/api/system/user";
  204. import { getToken } from "@/utils/auth";
  205. import { addCommonfile, allFileList, delCommonfile, updateCommonfile } from "@/api/rc/commonfile";
  206. export default {
  207. name: "Deptinfo",
  208. data() {
  209. return {
  210. // 遮罩层
  211. loading: true,
  212. // 选中数组
  213. ids: [],
  214. // 非单个禁用
  215. single: true,
  216. // 非多个禁用
  217. multiple: true,
  218. // 显示搜索条件
  219. showSearch: true,
  220. // 总条数
  221. total: 0,
  222. // 装置信息表格数据
  223. deptinfoList: [],
  224. // 弹出层标题
  225. title: "",
  226. // 是否显示弹出层
  227. open: false,
  228. // 查询参数
  229. queryParams: {
  230. pageNum: 1,
  231. pageSize: 10,
  232. deptInfo: null,
  233. deptId: null,
  234. year: null
  235. },
  236. // 表单参数
  237. form: {},
  238. // 表单校验
  239. rules: {
  240. },
  241. // 装置列表
  242. deptOptions: [],
  243. // 附件参数
  244. doc: {
  245. file: "",
  246. // 是否显示弹出层(报告附件)
  247. open: false,
  248. // 弹出层标题(报告附件)
  249. title: "附件",
  250. // 是否禁用上传
  251. isUploading: false,
  252. // 是否更新已经存在的用户数据
  253. updateSupport: 0,
  254. // 报告附件上传位置编号
  255. ids: 0,
  256. // 设置上传的请求头部
  257. headers: { Authorization: "Bearer " + getToken() },
  258. // 上传的地址
  259. url: process.env.VUE_APP_BASE_API + "/rc/commonfile/uploadFile",
  260. commonfileList: null,
  261. queryParams: {
  262. pId: null,
  263. pType: ''
  264. },
  265. pType: '',
  266. pId: null,
  267. form: {}
  268. },
  269. };
  270. },
  271. created() {
  272. this.getList();
  273. this.getDeptList();
  274. },
  275. methods: {
  276. /** 附件按钮操作 */
  277. handleDoc(row , type) {
  278. var typeName = "";
  279. if (type === "deptinfo-plane"){
  280. typeName = "平面图";
  281. } else if (type === "deptinfo-welcome"){
  282. typeName = "欢迎介绍";
  283. } else if (type === "deptinfo-video"){
  284. typeName = "视频介绍";
  285. }
  286. this.doc.pType = type
  287. this.doc.queryParams.pType = type
  288. this.doc.id = row.id;
  289. this.doc.title = row.deptName + typeName + "(" + new Date(row.year).getFullYear() + ")";
  290. this.doc.open = true;
  291. this.doc.queryParams.pId = row.id
  292. this.doc.pId = row.id
  293. this.getFileList();
  294. },
  295. getFileList(){
  296. allFileList(this.doc.queryParams).then(response => {
  297. this.doc.commonfileList = response;
  298. });
  299. },
  300. //附件上传中处理
  301. handleFileDocProgress(event, file, fileList) {
  302. this.doc.file = file;
  303. this.doc.isUploading = true;
  304. },
  305. //附件上传成功处理
  306. handleFileDocSuccess(response, file, fileList) {
  307. this.doc.isUploading = false;
  308. this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true });
  309. this.getFileList()
  310. this.$refs.doc.clearFiles();
  311. },
  312. // 文件下载处理
  313. handleDownload(row) {
  314. var name = row.fileName;
  315. var url = row.fileUrl;
  316. var suffix = url.substring(url.lastIndexOf("."), url.length);
  317. const a = document.createElement('a')
  318. a.setAttribute('download', name)
  319. a.setAttribute('target', '_blank')
  320. a.setAttribute('href', process.env.VUE_APP_BASE_API + url)
  321. a.click()
  322. },
  323. /** 删除按钮操作 */
  324. handleDeleteDoc(row) {
  325. const ids = row.id || this.ids;
  326. this.$confirm('是否确认删除?', '警告', {
  327. confirmButtonText: '确定',
  328. cancelButtonText: '取消',
  329. type: "warning"
  330. }).then(function() {
  331. return delCommonfile(ids);
  332. }).then(() => {
  333. this.getFileList()
  334. this.$message({
  335. message: '删除成功',
  336. type: 'success'
  337. });
  338. })
  339. },
  340. /** 查询装置信息列表 */
  341. getList() {
  342. this.loading = true;
  343. listDeptinfo(this.queryParams).then(response => {
  344. this.deptinfoList = response.rows;
  345. this.total = response.total;
  346. this.loading = false;
  347. });
  348. },
  349. /** 查询装置列表 */
  350. getDeptList() {
  351. listDept().then(response => {
  352. let data = response.data;
  353. for (let i = 0; i < data.length; i++) {
  354. // 非顶级节点
  355. if (data[i].parentId !== 0) {
  356. // 插入装置列表
  357. this.deptOptions.push({"dictLabel": data[i].deptName, "dictValue": data[i].deptId + ""});
  358. }
  359. }
  360. });
  361. },
  362. // 取消按钮
  363. cancel() {
  364. this.open = false;
  365. this.reset();
  366. },
  367. // 表单重置
  368. reset() {
  369. this.form = {
  370. id: null,
  371. deptInfo: null,
  372. deptId: null,
  373. year: null
  374. };
  375. this.resetForm("form");
  376. },
  377. /** 搜索按钮操作 */
  378. handleQuery() {
  379. this.queryParams.pageNum = 1;
  380. this.getList();
  381. },
  382. /** 重置按钮操作 */
  383. resetQuery() {
  384. this.resetForm("queryForm");
  385. this.handleQuery();
  386. },
  387. // 多选框选中数据
  388. handleSelectionChange(selection) {
  389. this.ids = selection.map(item => item.id)
  390. this.single = selection.length!==1
  391. this.multiple = !selection.length
  392. },
  393. /** 新增按钮操作 */
  394. handleAdd() {
  395. getUserDeptId().then(response => {
  396. this.reset();
  397. this.form.deptId = response.data + "";
  398. this.open = true;
  399. this.title = "添加装置信息";
  400. });
  401. },
  402. /** 修改按钮操作 */
  403. handleUpdate(row) {
  404. this.reset();
  405. const id = row.id || this.ids
  406. getDeptinfo(id).then(response => {
  407. this.form = response.data;
  408. this.open = true;
  409. this.title = "修改装置信息";
  410. });
  411. },
  412. /** 提交按钮 */
  413. submitForm() {
  414. this.$refs["form"].validate(valid => {
  415. if (valid) {
  416. if (this.form.id != null) {
  417. updateDeptinfo(this.form).then(response => {
  418. this.$modal.msgSuccess("修改成功");
  419. this.open = false;
  420. this.getList();
  421. });
  422. } else {
  423. addDeptinfo(this.form).then(response => {
  424. this.$modal.msgSuccess("新增成功");
  425. this.open = false;
  426. this.getList();
  427. });
  428. }
  429. }
  430. });
  431. },
  432. /** 删除按钮操作 */
  433. handleDelete(row) {
  434. const ids = row.id || this.ids;
  435. this.$modal.confirm('是否确认删除装置信息编号为"' + ids + '"的数据项?').then(function() {
  436. return delDeptinfo(ids);
  437. }).then(() => {
  438. this.getList();
  439. this.$modal.msgSuccess("删除成功");
  440. }).catch(() => {});
  441. },
  442. /** 导出按钮操作 */
  443. handleExport() {
  444. this.download('rc/deptinfo/export', {
  445. ...this.queryParams
  446. }, `deptinfo_${new Date().getTime()}.xlsx`)
  447. }
  448. }
  449. };
  450. </script>