|
@@ -33,7 +33,7 @@
|
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
|
<el-table-column label="护理时间" align="center" prop="nursingTime" width="180">
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="图片路径" align="center" prop="imgPaths" />
|
|
|
+
|
|
|
<el-table-column label="图片数量" align="center" prop="imgNum" />
|
|
|
<el-table-column label="备注" align="center" prop="remark" />
|
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
@@ -65,19 +65,14 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item label="图片路径" prop="imgPaths">
|
|
|
<el-upload
|
|
|
- v-model:file-list="fileList"
|
|
|
- class="upload-demo"
|
|
|
- :action=uploadImgUrl
|
|
|
- :on-preview="handlePreview"
|
|
|
+ v-model:file-list="fileLists"
|
|
|
+ :action="uploadImgUrl"
|
|
|
+ :headers="uploadHeaders"
|
|
|
+ list-type="picture-card"
|
|
|
:on-remove="handleRemove"
|
|
|
- list-type="picture"
|
|
|
+ :on-success="handleSuccess"
|
|
|
>
|
|
|
- <el-button type="primary">Click to upload</el-button>
|
|
|
- <template #tip>
|
|
|
- <div class="el-upload__tip">
|
|
|
- jpg/png files with a size less than 500kb
|
|
|
- </div>
|
|
|
- </template>
|
|
|
+ <el-icon><Plus /></el-icon>
|
|
|
</el-upload>
|
|
|
</el-form-item>
|
|
|
|
|
@@ -100,8 +95,10 @@
|
|
|
}
|
|
|
</style>
|
|
|
<script setup name="Clocks">
|
|
|
-import { listClocks, getClocks, delClocks, addClocks, updateClocks } from "@/api/care/clocks";
|
|
|
+import { listClocks, getClocks, delClocks, addClocks, updateClocks,removeImg } from "@/api/care/clocks";
|
|
|
import { ref } from 'vue'
|
|
|
+import { Plus } from '@element-plus/icons-vue'
|
|
|
+import { getToken } from '@/utils/auth'
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
|
|
|
const clocksList = ref([]);
|
|
@@ -113,9 +110,11 @@ const single = ref(true);
|
|
|
const multiple = ref(true);
|
|
|
const total = ref(0);
|
|
|
const title = ref("");
|
|
|
-const uploadImgUrl = ref(import.meta.env.VITE_APP_BASE_API + "/common/upload"); // 上传的图片服务器地址
|
|
|
-const fileList =ref([]);
|
|
|
|
|
|
+const fileLists =ref([]);
|
|
|
+
|
|
|
+const dialogImageUrl = ref('')
|
|
|
+const dialogVisible = ref(false)
|
|
|
// 定义 props
|
|
|
const props = defineProps({
|
|
|
applyId: {
|
|
@@ -149,6 +148,10 @@ const data = reactive({
|
|
|
|
|
|
const { queryParams, form, rules } = toRefs(data);
|
|
|
|
|
|
+const uploadImgUrl = ref(import.meta.env.VITE_APP_BASE_API + "/care/clocks/upload?applyId="+props.applyId+"&nursingDate="+form.value.nursingTime); // 上传的图片服务器地址
|
|
|
+const uploadHeaders={Authorization: 'Bearer ' + getToken()};
|
|
|
+const fileSize=1;
|
|
|
+
|
|
|
/** 查询护理任务打卡列表 */
|
|
|
function getList() {
|
|
|
loading.value = true;
|
|
@@ -181,6 +184,7 @@ function reset() {
|
|
|
remark: null,
|
|
|
applyId:props.applyId
|
|
|
};
|
|
|
+ fileLists.value=[]
|
|
|
proxy.resetForm("clocksRef");
|
|
|
}
|
|
|
|
|
@@ -216,6 +220,16 @@ function handleUpdate(row) {
|
|
|
const _clockId = row.clockId || ids.value
|
|
|
getClocks(_clockId).then(response => {
|
|
|
form.value = response.data;
|
|
|
+ const imgs=response.data.imgPaths.split(",").filter(item => item.trim() !== "");
|
|
|
+ imgs.forEach(function (item){
|
|
|
+ console.info(item)
|
|
|
+ const obj={};
|
|
|
+ obj.name=''
|
|
|
+ obj.url=import.meta.env.VITE_APP_BASE_API + item
|
|
|
+ console.info(obj)
|
|
|
+ fileLists.value.push(obj);
|
|
|
+ })
|
|
|
+
|
|
|
open.value = true;
|
|
|
title.value = "修改护理任务打卡";
|
|
|
});
|
|
@@ -223,13 +237,19 @@ function handleUpdate(row) {
|
|
|
|
|
|
/** 提交按钮 */
|
|
|
function submitForm() {
|
|
|
- form.value.imgNum=1;
|
|
|
- form.value.imgPaths="11111"
|
|
|
- // fileList.forEach(item => {
|
|
|
- // console.info(item);
|
|
|
- // form.value.imgNum++;
|
|
|
- // form.value.imgPaths+=item.url;
|
|
|
- // });
|
|
|
+ form.value.imgNum=0;
|
|
|
+ form.value.imgPaths=""
|
|
|
+ console.info(import.meta.env.VITE_APP_BASE_API+"---"+JSON.stringify(fileLists.value))
|
|
|
+ fileLists.value.forEach(item => {
|
|
|
+ console.info(item);
|
|
|
+ form.value.imgNum++;
|
|
|
+ if(item.response){
|
|
|
+ form.value.imgPaths+=item.response.imgUrl+",";
|
|
|
+ }else{
|
|
|
+ form.value.imgPaths+=item.url.replaceAll(import.meta.env.VITE_APP_BASE_API,"")+",";
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
|
|
|
proxy.$refs["clocksRef"].validate(valid => {
|
|
|
if (valid) {
|
|
@@ -268,13 +288,40 @@ function handleExport() {
|
|
|
}, `clocks_${new Date().getTime()}.xlsx`)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-function handlePreview(file) {
|
|
|
- console.log('预览文件:', file);
|
|
|
-}
|
|
|
function handleRemove(file, fileList) {
|
|
|
console.log('移除文件:', file, '剩余文件:', fileList);
|
|
|
+ //removeImg(file.response.imgUrl);
|
|
|
+}
|
|
|
+
|
|
|
+function handleBeforeUpload(file) {
|
|
|
+ if(form.value.nursingTime==null){
|
|
|
+ proxy.$modal.msgError('请选择护理时间!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const type = ["image/jpeg", "image/jpg", "image/png", "image/svg"];
|
|
|
+ const isJPG = type.includes(file.type);
|
|
|
+ // 检验文件格式
|
|
|
+ if (!isJPG) {
|
|
|
+ proxy.$modal.msgError('图片格式错误!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 校检文件大小
|
|
|
+ if (fileSize) {
|
|
|
+ const isLt = file.size / 1024 / 1024 < fileSize;
|
|
|
+ if (!isLt) {
|
|
|
+ proxy.$modal.msgError(`上传文件大小不能超过 ${fileSize} MB!`);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+function handleSuccess(response, file, fileList)
|
|
|
+{
|
|
|
+ if(response.code==200){
|
|
|
+ fileLists.value=fileList;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
getList();
|
|
|
</script>
|