main.vue 6.0 KB

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