main.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <ele-modal
  3. width="60%"
  4. :visible.sync="showEditFlag"
  5. :close-on-click-modal="false"
  6. custom-class="ele-dialog-form"
  7. append-to-body
  8. ref="Emodal"
  9. :maxable="true"
  10. :resizable="true"
  11. >
  12. <!-- 数据表格 -->
  13. <ele-pro-table
  14. ref="table"
  15. :columns="columns"
  16. :datasource="tableList"
  17. tool-class="ele-toolbar-form"
  18. :needPage="false"
  19. row-key="id"
  20. :cache-key="cacheKeyUrl"
  21. >
  22. <template v-slot:toolbar v-if="type != 'view'">
  23. <el-button type="primary" @click="fileEditOpen">本地上传</el-button>
  24. <el-button type="primary" @click="openFileList(0)">
  25. 关联文档库
  26. </el-button>
  27. <el-button type="primary" @click="openFileList(1)">
  28. 关联个人文档库
  29. </el-button>
  30. </template>
  31. <!-- 操作列 -->
  32. <template v-slot:action="{ row }">
  33. <el-link
  34. type="primary"
  35. :underline="false"
  36. icon="el-icon-edit"
  37. @click="browseOpen(row)"
  38. >
  39. 浏览
  40. </el-link>
  41. <el-popconfirm
  42. v-if="type != 'view'"
  43. class="ele-action"
  44. title="确定要删除吗?"
  45. @confirm="remove(row)"
  46. >
  47. <template v-slot:reference>
  48. <el-link type="danger" :underline="false" icon="el-icon-delete">
  49. 删除
  50. </el-link>
  51. </template>
  52. </el-popconfirm>
  53. </template>
  54. </ele-pro-table>
  55. <template v-slot:footer>
  56. <el-button @click="showEditFlag = false">取消</el-button>
  57. <el-button type="primary" @click="addFile" v-if="type != 'view'">
  58. 确认
  59. </el-button>
  60. </template>
  61. <fileEdit ref="fileEditRef" @done="done"></fileEdit>
  62. <ele-modal
  63. width="80%"
  64. :visible.sync="fileShow"
  65. :close-on-click-modal="false"
  66. custom-class="ele-dialog-form"
  67. append-to-body
  68. :maxable="true"
  69. :resizable="true"
  70. >
  71. <doc_template
  72. :disabledTableList="tableList"
  73. ref="doc_templateRef"
  74. ></doc_template>
  75. <template v-slot:footer>
  76. <el-button @click="fileShow = false">取消</el-button>
  77. <el-button type="primary" @click="addTemplate"> 确认 </el-button>
  78. </template>
  79. </ele-modal>
  80. <browse ref="browseRef"></browse>
  81. </ele-modal>
  82. </template>
  83. <script>
  84. import doc_template from './doc_template.vue';
  85. import fileEdit from './file-edit.vue';
  86. import browse from './browse.vue';
  87. import { queryIds } from './api';
  88. import { setFileUrl } from './util.js';
  89. export default {
  90. components: { doc_template, fileEdit, browse },
  91. data() {
  92. return {
  93. fileId: [],
  94. fileShow: false,
  95. showEditFlag: false,
  96. tableList: [],
  97. type: 'add',
  98. cacheKeyUrl: 'main-addDoc',
  99. tabMixinsInit: false,
  100. columns: [
  101. {
  102. label: '编码',
  103. prop: 'code',
  104. width: 180,
  105. align: 'center',
  106. showOverflowTooltip: true
  107. },
  108. {
  109. prop: 'name',
  110. label: '文档名称',
  111. align: 'center',
  112. slot: 'name',
  113. showOverflowTooltip: true,
  114. minWidth: 200
  115. },
  116. {
  117. prop: 'storagePath',
  118. label: '文件名称',
  119. align: 'center',
  120. showOverflowTooltip: true,
  121. minWidth: 200,
  122. formatter: (_row, _column, cellValue) => {
  123. return cellValue && cellValue[0]?.name;
  124. }
  125. },
  126. {
  127. prop: 'version',
  128. label: '版本',
  129. align: 'center',
  130. showOverflowTooltip: true,
  131. minWidth: 100
  132. },
  133. {
  134. prop: 'createUserName',
  135. label: '创建人',
  136. align: 'center',
  137. showOverflowTooltip: true,
  138. minWidth: 100
  139. },
  140. {
  141. prop: 'createTime',
  142. label: '创建时间',
  143. align: 'center',
  144. showOverflowTooltip: true,
  145. minWidth: 160
  146. },
  147. {
  148. prop: 'sizeUnit',
  149. label: '文档大小',
  150. align: 'center',
  151. showOverflowTooltip: true,
  152. minWidth: 100
  153. },
  154. {
  155. columnKey: 'action',
  156. label: '操作',
  157. width: 200,
  158. align: 'center',
  159. resizable: false,
  160. slot: 'action',
  161. showOverflowTooltip: true
  162. }
  163. ]
  164. };
  165. },
  166. created() {},
  167. methods: {
  168. openFileList(type) {
  169. this.fileShow = true;
  170. this.$nextTick(() => {
  171. this.$refs.doc_templateRef.query(type);
  172. });
  173. },
  174. open(fileId, type) {
  175. //查看详情:view 新增:add
  176. this.showEditFlag = true;
  177. this.fileId = fileId || [];
  178. if (type) {
  179. this.type = type;
  180. }
  181. this.init();
  182. },
  183. fileEditOpen() {
  184. this.$refs.fileEditRef.open();
  185. },
  186. remove(row) {
  187. this.tableList = this.tableList.filter((item) => item.code != row.code);
  188. this.fileId = this.tableList.map((item) => item.id);
  189. },
  190. async init() {
  191. if (this.fileId.length > 0) {
  192. if (typeof this.fileId[0] == 'object') {
  193. this.tableList = [];
  194. } else {
  195. this.tableList = await queryIds({ ids: "'" + this.fileId + "'" });
  196. }
  197. } else {
  198. this.tableList = [];
  199. }
  200. },
  201. done(id) {
  202. this.fileId.push(...id);
  203. this.init();
  204. },
  205. browseOpen(row) {
  206. window.open(setFileUrl(row));
  207. },
  208. addFile() {
  209. this.$emit(
  210. 'success',
  211. this.tableList.map((item) => item.id)
  212. );
  213. this.showEditFlag = false;
  214. },
  215. addTemplate() {
  216. let list = this.$refs.doc_templateRef.getTableList();
  217. this.fileShow = false;
  218. if (list.length == 0) {
  219. this.$message.error('请选择一条数据');
  220. return;
  221. }
  222. this.tableList.push(...list);
  223. }
  224. }
  225. };
  226. </script>