index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <div>
  3. <el-dialog v-model="isOpen" append-to-body width="950" @close="closeOpen" class="tank">
  4. <template #header>
  5. <div class="my-header">
  6. <div class="title">历史版本列表 — {{ name }}</div>
  7. </div>
  8. </template>
  9. <div class="main-conts">
  10. <div
  11. class="main-cont-left"
  12. style="display: flex; flex-direction: column"
  13. v-if="treeData.length>0"
  14. >
  15. <div
  16. v-for="(item, index) in treeData"
  17. :key="index"
  18. class="list-item list-item-dot"
  19. :class="{
  20. 'active-list-item list-item-dot-active': clickIndex == index,
  21. }"
  22. @click="clickList(index)"
  23. >
  24. <div>
  25. <span style="padding-left: 24px">{{ item.createTime }}</span>
  26. </div>
  27. <!-- 显示节点标签 -->
  28. <img :src="eyes" @click="previewFileClick(item)" class="eyes" />
  29. </div>
  30. </div>
  31. <div v-else style="text-align: center;">暂无历史版本记录</div>
  32. </div>
  33. <template #footer>
  34. <span class="dialog-footer" style="display: flex;align-items: center;justify-content: space-between;">
  35. <!-- <pagination
  36. v-show="total > 0"
  37. :total="total"
  38. v-model:page="pageNum"
  39. v-model:limit="pageSize"
  40. @pagination="getList"
  41. style="width: 70%;"
  42. /> -->
  43. <el-button @click="closeOpen" class="cancel-button">关闭</el-button>
  44. </span>
  45. </template>
  46. </el-dialog>
  47. <!-- <FileEdit :docId="docId" :copyRow="copyRow" :isEdit="false"></FileEdit> -->
  48. </div>
  49. </template>
  50. <script setup>
  51. import { nextTick, reactive, ref, toRaw, toRefs, watch,inject } from "vue";
  52. import FileEdit from "../../views/myfile/components/FileEdit.vue";
  53. import { ElMessage } from "element-plus";
  54. import fileImg from "@/assets/images/file-img.png";
  55. import activeCircle from "@/assets/images/active-circle.png";
  56. import morenCircle from "@/assets/images/moren-circle.png";
  57. import { listVersion } from "@/api/biz/version";
  58. import eyes from "@/assets/images/eyes.png";
  59. import useUserStore from "@/store/modules/user";
  60. import { defineEmits } from "vue";
  61. import {getInfo} from "@/api/biz/info.js"
  62. const props = defineProps({
  63. openFile: {
  64. type: Boolean,
  65. default: false,
  66. },
  67. fileUserTreeData: {
  68. type: Object,
  69. default: () => {},
  70. },
  71. docId: {
  72. type: Number,
  73. default: 0,
  74. },
  75. historyTotal: {
  76. type: Number,
  77. default: 0,
  78. },
  79. name: {
  80. type: String,
  81. default: "",
  82. },
  83. copyRow: {
  84. type: Object,
  85. required: true,
  86. },
  87. });
  88. const opent = ref(true);
  89. const total = ref(0);
  90. watchEffect(() => {
  91. // console.log('props.historyTotal', props.historyTotal)
  92. total.value=props.historyTotal
  93. });
  94. const addFileTab = inject("addFileTab");
  95. const pageNum=ref(1)
  96. const pageSize=ref(9999)
  97. const defaultProps = {
  98. children: "",
  99. label: "createTime",
  100. value: "docId",
  101. };
  102. const isOpen = ref(props.openFile);
  103. watch(
  104. () => props.openFile,
  105. (newValue) => {
  106. isOpen.value = newValue;
  107. }
  108. );
  109. // const treeData = reactive([]);
  110. const treeData = ref([]);
  111. watchEffect(() => {
  112. if(props.fileUserTreeData.length>0){
  113. treeData.value = props.fileUserTreeData.reverse();
  114. toRaw(treeData.value);
  115. // console.log('treeData',treeData.value);
  116. }
  117. });
  118. const getList=async()=>{
  119. // console.log('page', pageNum.value)
  120. try {
  121. const resHistory = await listVersion({ pageNum: pageNum.value, pageSize: pageSize.value, docId: props.docId });
  122. treeData.value = resHistory.rows;
  123. // console.log('treeData.value', treeData.value);
  124. total.value = resHistory.total;
  125. } catch (error) {
  126. console.error(error);
  127. }
  128. }
  129. //树
  130. const clickData = ref({});
  131. const handleNodeClick = (data) => {
  132. clickData.value = data;
  133. };
  134. const clickIndex = ref("");
  135. const emit = defineEmits(["changeMsgClose",'setHisData']);
  136. //点击预览
  137. const previewFileClick =async (item) => {
  138. // console.log('preitem',item);
  139. // const res =await getInfo(item.docId)
  140. // console.log('res',res);
  141. // addFileTab(res.data,0,0,1,item.fileId);
  142. emit("setHisData", item);
  143. isOpen.value = false;
  144. };
  145. const clickList = (index) => {
  146. clickIndex.value = index;
  147. };
  148. const closeOpen = () => {
  149. // console.log('first', isOpen.value)
  150. isOpen.value = false;
  151. emit("changeMsgClose", false, "");
  152. };
  153. </script>
  154. <style lang="scss" scoped>
  155. @import "@/assets/styles/tree-common.scss";
  156. // .footer-main{
  157. // display: flex;
  158. // align-items: center;
  159. // }
  160. .main-conts {
  161. height: 348px;
  162. border: 1px solid #c1cce3;
  163. // display: flex;
  164. .main-cont-left,
  165. .main-cont-right {
  166. width: 100%;
  167. height: 100%;
  168. overflow-y: auto;
  169. }
  170. .main-cont-right {
  171. border-left: 1px solid #c1cce3;
  172. }
  173. }
  174. .eyes {
  175. width: 22px;
  176. height: 22px;
  177. cursor: pointer;
  178. }
  179. .list-item {
  180. display: flex;
  181. justify-content: space-between;
  182. align-items: center;
  183. padding: 12px 16px;
  184. height: 46px;
  185. background: #fff;
  186. }
  187. .list-item-dot {
  188. position: relative;
  189. }
  190. .list-item-dot::before {
  191. content: "";
  192. background-image: url("@/assets/images/moren-circle.png");
  193. background-size: 14px;
  194. position: absolute;
  195. top: 50%;
  196. left: 33.5;
  197. transform: translate(-50%, -50%);
  198. width: 14px;
  199. height: 14px;
  200. }
  201. .list-item:not(:first-child)::after {
  202. content: "";
  203. position: absolute;
  204. top: 1%;
  205. left: 1.7%;
  206. transform: translate(0, -50%);
  207. width: 1.5px;
  208. height: 60%;
  209. background-color: #c1cce3; /* 连线的颜色 */
  210. }
  211. .list-item-dot-active::before {
  212. background-image: url("@/assets/images/active-circle.png");
  213. }
  214. .active-list-item {
  215. background: #f5f7f9;
  216. }
  217. .cancel-button {
  218. background: #2e6bc8;
  219. color: #fff;
  220. border: none;
  221. width: 120px;
  222. height: 32px;
  223. z-index: 999;
  224. }
  225. .main-conts {
  226. border: none;
  227. // overflow: auto;
  228. }
  229. :deep(.pagination-container .el-pagination){
  230. left:25px;
  231. bottom: 36px;
  232. }
  233. </style>