index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <div class="abstract">
  3. <el-tabs v-model="activeName" class="demo-tabs h-full" @tab-click="handleClick">
  4. <el-tab-pane label="现场图" name="1">
  5. <div class="xct">
  6. <el-button
  7. style="width: calc(50% - 7px)"
  8. type="primary"
  9. @click="submitForm(ruleFormRef)"
  10. >
  11. 绘制平面图
  12. </el-button>
  13. <el-button
  14. style="width: calc(50% - 6px)"
  15. type="primary"
  16. @click="submitForm(ruleFormRef)"
  17. >
  18. AI 平面图
  19. </el-button>
  20. <el-button
  21. class="w-full mt-4"
  22. style="margin-left: 0"
  23. type="primary"
  24. @click="submitForm(ruleFormRef)"
  25. >
  26. 绘制方位图
  27. </el-button>
  28. <div class="phote my-4 w-full" v-for="item,index in list.xct" :key="index">
  29. <p class="pb-4">{{item.filesTypeName}}</p>
  30. <div class="pmt-phote w-full flex justify-between ">
  31. <viewImg :list="item.caseFilesList || []" @handleItem="handleItem" height="66px" />
  32. </div>
  33. </div>
  34. </div>
  35. </el-tab-pane>
  36. <el-tab-pane class="h-full" label="现场照片" name="2">
  37. <div class="scene h-full">
  38. <el-button class="w-full" @click="handleAdd(['三录材料', '现场照片'])">上传</el-button>
  39. <!-- <el-button class="w-full my-4" style="margin-left: 0; margin-right: 0">添加场景</el-button> -->
  40. <div class="scene-list">
  41. <div class="list">
  42. <div class="listItem py-2" v-for="item,index in list.xczp" :key="index">
  43. <div class="title1">{{item.filesTypeName}}</div>
  44. <div class="list2" v-for="item2,index2 in item.childrenList" :key="index2">
  45. <div class="title2">{{item2.filesTypeName}}</div>
  46. <viewImg :list="item2.caseFilesList || []" @handleItem="handleItem" />
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. <el-button class="w-full" @click="handleAdd()">照片制卷</el-button>
  52. </div>
  53. </el-tab-pane>
  54. <el-tab-pane label="勘验笔录" name="3">
  55. <div class="blfrom">
  56. <el-upload
  57. class="upload-demo"
  58. :multiple="false"
  59. :show-file-list="false"
  60. drag
  61. :limit="1"
  62. :before-upload="upload"
  63. :file-list="fileList"
  64. :http-request="uploadNewFile"
  65. :on-success="handleSuccess"
  66. :on-preview="previewFile"
  67. :accept="accept"
  68. :before-remove="removeFile"
  69. >
  70. <div type="primary" :disabled="!!file">
  71. <div>点击或拖拽文件上传</div>
  72. <div class="">支持 pdf、word 格式图片上传</div>
  73. </div>
  74. </el-upload>
  75. <el-button class="w-full mt-2" @click="handleAdd">在线填写</el-button>
  76. </div>
  77. <div class="blList">
  78. <div class="bllistItem flex justify-between items-center mt-2" v-for="item,index in list.klbj" :key="index">
  79. <div>{{item.filesTitle}}</div>
  80. <el-dropdown @command="(command)=>{handleCommand(command, item)}">
  81. <el-icon>
  82. <MoreFilled />
  83. </el-icon>
  84. <template #dropdown>
  85. <el-dropdown-menu>
  86. <el-dropdown-item command="edit">编辑</el-dropdown-item>
  87. <el-dropdown-item command="delete">删除</el-dropdown-item>
  88. <el-dropdown-item command="down">下载</el-dropdown-item>
  89. </el-dropdown-menu>
  90. </template>
  91. </el-dropdown>
  92. </div>
  93. </div>
  94. </el-tab-pane>
  95. </el-tabs>
  96. </div>
  97. </template>
  98. <script setup lang="ts">
  99. import { uploadNewFile, addByMediaLiBrary } from "@/store/case";
  100. import { computed, ref, reactive } from "vue";
  101. import { addCaseFile } from "../originalPhoto/quisk";
  102. import { ElMessage, ElMessageBox } from "element-plus";
  103. import { useUpload } from "@/hook/upload";
  104. import { router } from "@/router";
  105. import { updateByTreeFileLists, getByTreeFileLists } from "@/store/case";
  106. import { Delete, Edit } from "@element-plus/icons-vue";
  107. import viewImg from "@/components/viewImg/index.vue"
  108. import { delCaseFile, } from "@/store/caseFile";
  109. const caseId = computed(() => (router.currentRoute.value?.params?.caseId));
  110. const active = ref(true);
  111. const list = ref({
  112. xct:[],
  113. xczp:[],
  114. klbj:[],
  115. });
  116. getList()
  117. const srcList = [
  118. "https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg",
  119. "https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg",
  120. ];
  121. const settype = ref(false);
  122. const ruleFormRef = ref(null);
  123. const klblId = ref(0);
  124. const activeName = ref('1');
  125. const showModal = ref(false);
  126. const { size, fileList, upload, removeFile, previewFile, file, accept } =
  127. useUpload({
  128. maxSize: 10 * 1024 * 1024,
  129. formats: [".doc", ".docx", , ".pdf"],
  130. });
  131. const handleClick = (tab) => {
  132. console.log(tab);
  133. };
  134. function getList() {
  135. updateByTreeFileLists(caseId.value).then(res => {
  136. let newlist = res.find(ele => ele.filesTypeName == '三录材料')?.childrenList || [];
  137. list.value.xct = newlist.find(ele => ele.filesTypeName == '现场图')?.childrenList || [];
  138. list.value.xczp = newlist.find(ele => ele.filesTypeName == '现场照片')?.childrenList || [];
  139. list.value.klbj = newlist.find(ele => ele.filesTypeName == '勘验笔录')?.caseFilesList || [];
  140. klblId.value = newlist.find(ele => ele.filesTypeName == '勘验笔录').filesTypeId
  141. console.log('list.value', list.value)
  142. })
  143. }
  144. const submitForm = async (formEl) => {
  145. if (!formEl) return;
  146. await formEl.validate((valid, fields) => {
  147. if (valid) {
  148. console.log("submit!");
  149. } else {
  150. console.log("error submit!", fields);
  151. }
  152. });
  153. };
  154. const resetForm = (formEl) => {
  155. if (!formEl) return;
  156. formEl.resetFields();
  157. };
  158. function handleActive(params) {
  159. console.log("handleActive", params);
  160. }
  161. function handleItem(type, item) {
  162. console.log("handleItem", type, item);
  163. }
  164. function handleSuccess(item) {
  165. let uploadId = item?.data.id;
  166. addByMediaLiBrary({ caseId: caseId.value, filesTypeId: klblId.value, uploadId }).then((res) => {
  167. getList();
  168. });
  169. }
  170. async function handleAdd(filesTypeName) {
  171. await addCaseFile({ caseId: caseId.value, fileType: 1, filesTypeName });
  172. getList()
  173. console.log("handleAdd");
  174. }
  175. const handleCommand = (command: string | number | object, item) => {
  176. switch (command) {
  177. case "edit":
  178. ElMessage(`click on item ${command}`)
  179. break;
  180. case "delete":
  181. handleDel(item)
  182. break;
  183. default:
  184. console.log("other", command);
  185. }
  186. // ElMessage(`click on item ${command}`)
  187. }
  188. function handleDel(item) {
  189. ElMessageBox.confirm("确定删除?", "提示", {
  190. confirmButtonText: "确定",
  191. cancelButtonText: "取消",
  192. type: "warning",
  193. }).then(async () => {
  194. await delCaseFile({ caseId: caseId.value, filesId: item.filesId });
  195. ElMessage({
  196. type: "success",
  197. message: "删除成功",
  198. });
  199. getList()
  200. });
  201. }
  202. </script>
  203. <style lang="scss" scoped>
  204. .abstract {
  205. height: 100%;
  206. .el-tab-pane{
  207. height: 100%;
  208. overflow-y: scroll;
  209. position: relative;
  210. }
  211. .el-form-item--label-top {
  212. margin-bottom: 14px;
  213. }
  214. .form-content {
  215. height: calc(100vh - 225px);
  216. overflow-y: scroll;
  217. }
  218. .demo-tabs {
  219. .el-tabs__item {
  220. height: 32px;
  221. line-height: 32px;
  222. }
  223. }
  224. }
  225. </style>