index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <!--目录数据-->
  5. <el-col :span="4" :xs="24">
  6. <div class="head-container">
  7. <el-tree :data="dirList" :props="defaultProps" :expand-on-click-node="false" ref="tree" node-key="id"
  8. default-expand-all highlight-current @node-click="handleNodeClick" />
  9. </div>
  10. </el-col>
  11. <!--文档数据-->
  12. <el-col :span="16" :xs=24>
  13. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
  14. label-width="68px">
  15. <el-form-item label="文档名称" prop="docName">
  16. <el-input v-model="queryParams.docName" placeholder="请输入文档名称" clearable @keyup.enter.native="handleQuery" />
  17. </el-form-item>
  18. <el-form-item label="文档级别" prop="docLevel">
  19. <el-input v-model="queryParams.docLevel" placeholder="请输入文档级别" clearable
  20. @keyup.enter.native="handleQuery" />
  21. </el-form-item>
  22. <el-form-item label="文档年份" prop="createYear">
  23. <el-input v-model="queryParams.createYear" placeholder="请输入文档创建年份" clearable
  24. @keyup.enter.native="handleQuery" />
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  28. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  29. </el-form-item>
  30. </el-form>
  31. <el-row :gutter="10" class="mb8">
  32. <el-col :span="1.5">
  33. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  34. v-hasPermi="['doc:info:add']">上传</el-button>
  35. </el-col>
  36. <el-col :span="1.5">
  37. <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
  38. v-hasPermi="['doc:info:edit']">修改</el-button>
  39. </el-col>
  40. <el-col :span="1.5">
  41. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
  42. v-hasPermi="['doc:info:remove']">删除</el-button>
  43. </el-col>
  44. <el-col :span="1.5">
  45. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
  46. v-hasPermi="['doc:info:export']">导出</el-button>
  47. </el-col>
  48. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  49. </el-row>
  50. <el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
  51. <el-table-column type="selection" width="55" align="center" />
  52. <el-table-column label="文档ID" align="center" prop="docId" />
  53. <el-table-column label="文档名称" align="center" prop="docName" />
  54. <el-table-column label="文档级别" align="center" prop="docLevel" />
  55. <el-table-column label="文档年份" align="center" prop="createYear" />
  56. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  57. <template slot-scope="scope">
  58. <el-button size="mini" type="text" icon="el-icon-view" @click="handlePreview(scope.row)">预览</el-button>
  59. <el-button size="mini" type="text" icon="el-icon-view" @click="handleEdit(scope.row)">在线编辑</el-button>
  60. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  61. v-hasPermi="['doc:info:edit']">修改</el-button>
  62. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  63. v-hasPermi="['doc:info:remove']">删除</el-button>
  64. </template>
  65. </el-table-column>
  66. </el-table>
  67. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  68. @pagination="getList" />
  69. </el-col>
  70. </el-row>
  71. <!-- 添加或修改文档基本信息对话框 -->
  72. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  73. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  74. <el-form-item label="" prop="docPath">
  75. <!-- <el-input v-model="form.docPath" placeholder="请输入文档路径" /> -->
  76. <file-upload v-model="form.docPath" />
  77. </el-form-item>
  78. <el-form-item label="文件名称" prop="docName">
  79. <el-input v-model="form.docName" placeholder="请输入文档名称" />
  80. </el-form-item>
  81. <el-form-item label="文件描述">
  82. <el-input v-model="form.docDesc" type="textarea" placeholder="请输入内容" />
  83. </el-form-item>
  84. <el-form-item label="文件级别" prop="docLevel">
  85. <el-input v-model="form.docLevel" placeholder="请输入文档级别" />
  86. </el-form-item>
  87. </el-form>
  88. <div slot="footer" class="dialog-footer">
  89. <el-button type="primary" @click="submitForm">确 定</el-button>
  90. <el-button @click="cancel">取 消</el-button>
  91. </div>
  92. </el-dialog>
  93. </div>
  94. </template>
  95. <script>
  96. import {
  97. listInfo,
  98. getInfo,
  99. delInfo,
  100. addInfo,
  101. updateInfo
  102. } from "@/api/doc/info";
  103. import {
  104. listDir,
  105. getDir,
  106. delDir,
  107. addDir,
  108. updateDir,
  109. personalList
  110. } from "@/api/doc/dir";
  111. import Treeselect from "@riophae/vue-treeselect";
  112. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  113. export default {
  114. name: "Info",
  115. components: {
  116. Treeselect
  117. },
  118. data() {
  119. return {
  120. // 遮罩层
  121. loading: true,
  122. // 选中数组
  123. ids: [],
  124. // 非单个禁用
  125. single: true,
  126. // 非多个禁用
  127. multiple: true,
  128. // 显示搜索条件
  129. showSearch: true,
  130. // 总条数
  131. total: 0,
  132. // 文档基本信息表格数据
  133. infoList: [],
  134. dirId: undefined, //目录ID
  135. dirList: undefined,
  136. // 弹出层标题
  137. title: "",
  138. // 是否显示弹出层
  139. open: false,
  140. // 查询参数
  141. queryParams: {
  142. pageNum: 1,
  143. pageSize: 10,
  144. docName: null,
  145. docLevel: null,
  146. createYear: null,
  147. },
  148. // 表单参数
  149. form: {},
  150. defaultProps: {
  151. children: "children",
  152. label: "dirName",
  153. id: "dirId"
  154. },
  155. // 表单校验
  156. rules: {
  157. docName: [{
  158. required: true,
  159. message: "文档名称不能为空",
  160. trigger: "blur"
  161. }],
  162. createYear: [{
  163. required: true,
  164. message: "文档创建年份;文档创建年份,分表用不能为空",
  165. trigger: "blur"
  166. }],
  167. }
  168. }
  169. },
  170. created() {
  171. this.getList();
  172. this.dirTree();
  173. },
  174. methods: {
  175. //目录树
  176. dirTree() {
  177. personalList().then(response => {
  178. this.dirId = response.data[0].dirId;
  179. this.dirList = this.handleTree(response.data, "dirId");
  180. this.loading = false;
  181. });
  182. },
  183. // 节点单击事件
  184. handleNodeClick(data) {
  185. this.queryParams.dirId = data.dirId;
  186. this.dirId = data.dirId;
  187. this.handleQuery();
  188. },
  189. //预览
  190. handlePreview(row) {
  191. row.isEdit = false;
  192. this.$tab.openPage("文件[" + row.docName + "]预览", '/doc/oo-edit/index/' + row.docId, row);
  193. },
  194. //在线编辑
  195. handleEdit(row) {
  196. row.isEdit = true;
  197. this.$tab.openPage("文件[" + row.docName + "]在线编辑", '/doc/oo-edit/index/' + row.docId, row);
  198. },
  199. /** 查询文档基本信息列表 */
  200. getList() {
  201. this.loading = true;
  202. listInfo(this.queryParams).then(response => {
  203. this.infoList = response.rows;
  204. this.total = response.total;
  205. this.loading = false;
  206. });
  207. },
  208. // 取消按钮
  209. cancel() {
  210. this.open = false;
  211. this.reset();
  212. },
  213. // 表单重置
  214. reset() {
  215. this.form = {
  216. docId: null,
  217. dirId: this.dirId,
  218. docName: null,
  219. docType: null,
  220. docSize: null,
  221. classifyId: null,
  222. docDesc: null,
  223. docPath: null,
  224. docLevel: null,
  225. allowEdit: null,
  226. docOf: null,
  227. owner: null,
  228. createYear: null,
  229. createBy: null,
  230. createTime: null,
  231. updateBy: null,
  232. updateTime: null,
  233. remark: null,
  234. isDel: null
  235. };
  236. this.resetForm("form");
  237. },
  238. /** 搜索按钮操作 */
  239. handleQuery() {
  240. this.queryParams.pageNum = 1;
  241. this.getList();
  242. },
  243. /** 重置按钮操作 */
  244. resetQuery() {
  245. this.resetForm("queryForm");
  246. this.handleQuery();
  247. },
  248. // 多选框选中数据
  249. handleSelectionChange(selection) {
  250. this.ids = selection.map(item => item.docId)
  251. this.single = selection.length !== 1
  252. this.multiple = !selection.length
  253. },
  254. /** 新增按钮操作 */
  255. handleAdd() {
  256. this.reset();
  257. this.open = true;
  258. this.title = "添加文档基本信息";
  259. },
  260. /** 修改按钮操作 */
  261. handleUpdate(row) {
  262. this.reset();
  263. const docId = row.docId || this.ids
  264. getInfo(docId, row.createYear).then(response => {
  265. this.form = response.data;
  266. this.open = true;
  267. this.title = "修改文档基本信息";
  268. });
  269. },
  270. /** 提交按钮 */
  271. submitForm() {
  272. this.$refs["form"].validate(valid => {
  273. if (valid) {
  274. if (this.form.docId != null) {
  275. updateInfo(this.form).then(response => {
  276. this.$modal.msgSuccess("修改成功");
  277. this.open = false;
  278. this.getList();
  279. });
  280. } else {
  281. addInfo(this.form).then(response => {
  282. this.$modal.msgSuccess("新增成功");
  283. this.open = false;
  284. this.getList();
  285. });
  286. }
  287. }
  288. });
  289. },
  290. /** 删除按钮操作 */
  291. handleDelete(row) {
  292. const docIds = row.docId || this.ids;
  293. this.$modal.confirm('是否确认删除文档基本信息编号为"' + docIds + '"的数据项?').then(function() {
  294. return delInfo(docIds);
  295. }).then(() => {
  296. this.getList();
  297. this.$modal.msgSuccess("删除成功");
  298. }).catch(() => {});
  299. },
  300. /** 导出按钮操作 */
  301. handleExport() {
  302. this.download('doc/info/export', {
  303. ...this.queryParams
  304. }, `info_${new Date().getTime()}.xlsx`)
  305. }
  306. }
  307. };
  308. </script>