index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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 } 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. const props = defineProps({
  62. openFile: {
  63. type: Boolean,
  64. default: false,
  65. },
  66. fileUserTreeData: {
  67. type: Object,
  68. default: () => {},
  69. },
  70. docId: {
  71. type: Number,
  72. default: 0,
  73. },
  74. historyTotal: {
  75. type: Number,
  76. default: 0,
  77. },
  78. name: {
  79. type: String,
  80. default: "",
  81. },
  82. copyRow: {
  83. type: Object,
  84. required: true,
  85. },
  86. });
  87. const opent = ref(true);
  88. const total = ref(0);
  89. watchEffect(() => {
  90. console.log('props.historyTotal', props.historyTotal)
  91. total.value=props.historyTotal
  92. });
  93. const pageNum=ref(1)
  94. const pageSize=ref(10)
  95. const defaultProps = {
  96. children: "",
  97. label: "createTime",
  98. value: "docId",
  99. };
  100. const isOpen = ref(props.openFile);
  101. watch(
  102. () => props.openFile,
  103. (newValue) => {
  104. isOpen.value = newValue;
  105. }
  106. );
  107. // const treeData = reactive([]);
  108. const treeData = ref([]);
  109. watchEffect(() => {
  110. if(props.fileUserTreeData.length>0){
  111. treeData.value = props.fileUserTreeData.reverse();
  112. toRaw(treeData.value);
  113. console.log('treeData',treeData.value);
  114. }
  115. });
  116. const getList=async()=>{
  117. console.log('page', pageNum.value)
  118. try {
  119. const resHistory = await listVersion({ pageNum: pageNum.value, pageSize: pageSize.value, docId: props.docId });
  120. treeData.value = resHistory.rows;
  121. console.log('treeData.value', treeData.value);
  122. total.value = resHistory.total;
  123. } catch (error) {
  124. console.error(error);
  125. }
  126. }
  127. //树
  128. const clickData = ref({});
  129. const handleNodeClick = (data) => {
  130. clickData.value = data;
  131. };
  132. const clickIndex = ref("");
  133. const emit = defineEmits(["changeMsgClose"]);
  134. //点击预览
  135. const previewFileClick = (item) => {
  136. emit("changeMsgClose", true, item);
  137. isOpen.value = false;
  138. };
  139. const clickList = (index) => {
  140. clickIndex.value = index;
  141. };
  142. const closeOpen = () => {
  143. console.log('first', isOpen.value)
  144. isOpen.value = false;
  145. emit("changeMsgClose", false, "");
  146. };
  147. </script>
  148. <style lang="scss" scoped>
  149. @import "@/assets/styles/tree-common.scss";
  150. // .footer-main{
  151. // display: flex;
  152. // align-items: center;
  153. // }
  154. .main-conts {
  155. height: 348px;
  156. border: 1px solid #c1cce3;
  157. // display: flex;
  158. .main-cont-left,
  159. .main-cont-right {
  160. width: 100%;
  161. height: 100%;
  162. overflow-y: auto;
  163. }
  164. .main-cont-right {
  165. border-left: 1px solid #c1cce3;
  166. }
  167. }
  168. .eyes {
  169. width: 22px;
  170. height: 22px;
  171. cursor: pointer;
  172. }
  173. .list-item {
  174. display: flex;
  175. justify-content: space-between;
  176. align-items: center;
  177. padding: 12px 16px;
  178. height: 46px;
  179. background: #fff;
  180. }
  181. .list-item-dot {
  182. position: relative;
  183. }
  184. .list-item-dot::before {
  185. content: "";
  186. background-image: url("@/assets/images/moren-circle.png");
  187. background-size: 14px;
  188. position: absolute;
  189. top: 50%;
  190. left: 33.5;
  191. transform: translate(-50%, -50%);
  192. width: 14px;
  193. height: 14px;
  194. }
  195. .list-item:not(:first-child)::after {
  196. content: "";
  197. position: absolute;
  198. top: 1%;
  199. left: 1.7%;
  200. transform: translate(0, -50%);
  201. width: 1.5px;
  202. height: 60%;
  203. background-color: #c1cce3; /* 连线的颜色 */
  204. }
  205. .list-item-dot-active::before {
  206. background-image: url("@/assets/images/active-circle.png");
  207. }
  208. .active-list-item {
  209. background: #f5f7f9;
  210. }
  211. .cancel-button {
  212. background: #2e6bc8;
  213. color: #fff;
  214. border: none;
  215. width: 120px;
  216. height: 32px;
  217. z-index: 999;
  218. }
  219. .main-conts {
  220. border: none;
  221. // overflow: auto;
  222. }
  223. :deep(.pagination-container .el-pagination){
  224. left:25px;
  225. bottom: 36px;
  226. }
  227. </style>