index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <div>
  3. <div class="flex-align-center flex-between normal-margin">
  4. <div v-if="$slots.title">
  5. <slot name="title"></slot>
  6. </div>
  7. <!-- <p v-else>附件列表</p> -->
  8. <slot v-if="!onlyread" name="upload"></slot>
  9. </div>
  10. <el-table
  11. :header-cell-style="{background:'#EEEEEE',color:'#333'}"
  12. size="mini"
  13. border
  14. :data="attinfos"
  15. style="width: 100%"
  16. >
  17. <el-table-column prop="document" label="文件名称">
  18. <template slot-scope="scope">
  19. <el-input
  20. v-if="actid === scope.row.attachmentid"
  21. size="mini"
  22. v-model="scope.row.document"
  23. ></el-input>
  24. <span v-else>{{scope.row.document}}</span>
  25. </template>
  26. </el-table-column>
  27. <el-table-column prop="createdate" label="上传时间"></el-table-column>
  28. <el-table-column prop="contentlength" label="文件大小" width="90">
  29. <template
  30. slot-scope="scope"
  31. >{{scope.row.contentlength > 1073741824?(scope.row.contentlength / Math.pow(1024,3)).toFixed(2)+'GB':scope.row.contentlength > 1048576?(scope.row.contentlength / Math.pow(1024,2)).toFixed(2)+'MB':scope.row.contentlength > 1024?(scope.row.contentlength / Math.pow(1024,1)).toFixed(2)+'KB':scope.row.contentlength+'B'}}</template>
  32. </el-table-column>
  33. <el-table-column label="操作" width="170">
  34. <template slot-scope="scope">
  35. <div v-if="actid === scope.row.attachmentid">
  36. <el-button
  37. type="text"
  38. size="small"
  39. @click="saveEdit(scope.row)"
  40. :disabled="status === '已失败' || status === '已结案' || attachmentDisabled"
  41. >保 存</el-button>
  42. <el-button
  43. type="text"
  44. size="small"
  45. @click="refresh(actid = 0)"
  46. :disabled="status === '已失败' || status === '已结案' || attachmentDisabled"
  47. >取 消</el-button>
  48. </div>
  49. <div v-else>
  50. <el-button
  51. type="text"
  52. size="small"
  53. @click="download(scope.row)"
  54. :disabled="status === '已失败' || status === '已结案'"
  55. >下 载</el-button>
  56. <el-button type="text" size="small" @click="seeClick(scope.row)">预 览</el-button>
  57. <el-button
  58. :disabled="onlyread || status === '已失败' || status === '已结案' || attachmentDisabled "
  59. class="inline-16"
  60. type="text"
  61. size="small"
  62. @click="editAttachment(scope.row)"
  63. >编 辑</el-button>
  64. <el-popconfirm title="确定删除当前附件吗?" @confirm="deleteAttachment(scope.row)">
  65. <el-button
  66. :disabled="onlyread || status === '已失败' || status === '已结案' || scope.row.usetype === 'undelete' || attachmentDisabled"
  67. slot="reference"
  68. size="small"
  69. type="text"
  70. >删 除</el-button>
  71. </el-popconfirm>
  72. </div>
  73. </template>
  74. </el-table-column>
  75. </el-table>
  76. <SeeFile ref="seeFile" :fileData="seeFile"></SeeFile>
  77. </div>
  78. </template>
  79. <script>
  80. import SeeFile from "@/components/file-block/components/SeeFile1";
  81. export default {
  82. props: ["attinfos", "onlyread", "status","attachmentDisabled"],
  83. data() {
  84. return {
  85. actid: null,
  86. seeFile: "",
  87. isSeeFileShow: false,
  88. };
  89. },
  90. components: { SeeFile },
  91. methods: {
  92. refresh() {
  93. this.$emit("cancelEdit");
  94. },
  95. editAttachment(row) {
  96. this.actid = row.attachmentid;
  97. },
  98. download(row) {
  99. window.open(row.url);
  100. this.downloadRecord(row);
  101. },
  102. /*保存下载操作记录*/
  103. async downloadRecord(row) {
  104. const res = await this.$api.requested({
  105. id: 10020701,
  106. content: {
  107. linksid: row.linksid,
  108. attachmentid: row.attachmentid,
  109. },
  110. });
  111. },
  112. async saveEdit(row) {
  113. let param = {
  114. classname: "system.attachment.MediaCenter",
  115. method: "changeAttachment",
  116. content: {
  117. files: [
  118. {
  119. attachmentid: row.attachmentid,
  120. document: row.document,
  121. parentid: row.parentid,
  122. },
  123. ],
  124. },
  125. };
  126. const res = await this.$api.requested(param);
  127. res.code === 1 ? this.$emit("onSuccess") : "";
  128. res.code === 1 ? (this.actid = "") : "";
  129. },
  130. async deleteAttachment(row) {
  131. const res = await this.$api.requested({
  132. classname: "system.attachment.Attachment",
  133. method: "deleteFileLink",
  134. content: {
  135. linksids: [row.linksid],
  136. },
  137. });
  138. res.code === 1 ? this.tool.showMessage(res) : "";
  139. res.code === 1 ? this.$emit("onSuccess") : "";
  140. },
  141. seeClick(item) {
  142. console.log(item);
  143. if (
  144. item.postfix == "png" ||
  145. item.postfix == "PNG" ||
  146. item.postfix == "jpg" ||
  147. item.postfix == "JPG" ||
  148. item.postfix == "bmp" ||
  149. item.postfix == "BMP" ||
  150. item.postfix == "gif" ||
  151. item.postfix == "GIG" ||
  152. item.postfix == "WEBP" ||
  153. item.postfix == "webp" ||
  154. item.postfix == "svg" ||
  155. item.postfix == "SVG" ||
  156. item.postfix == "TIFF" ||
  157. item.postfix == "tiff" ||
  158. item.postfix == "MP4" ||
  159. item.postfix == "mp4" ||
  160. item.postfix == "ogg" ||
  161. item.postfix == "webm"
  162. ) {
  163. this.seeFile = item;
  164. this.$refs.seeFile.dialogVisible = true;
  165. } else if (item.postfix == "PDF" || item.postfix == "pdf") {
  166. window.open(item.url, "_blank");
  167. } else {
  168. this.$notify({
  169. title: "提示",
  170. message: "该文件暂不支持",
  171. type: "warning",
  172. });
  173. }
  174. },
  175. },
  176. };
  177. </script>
  178. <style>
  179. </style>