|
@@ -104,20 +104,20 @@
|
|
|
<van-uploader
|
|
|
:after-read="afterRead"
|
|
|
v-model="fileList"
|
|
|
- :max-count="1"
|
|
|
+ :max-count="6"
|
|
|
capture="camera"
|
|
|
accept=""
|
|
|
+ :before-delete="fjdelete"
|
|
|
>
|
|
|
<van-button icon="plus">上传文件</van-button>
|
|
|
- <template #preview-cover="file">
|
|
|
+ <!-- <template #preview-cover="file">
|
|
|
<div class="preview-cover van-ellipsis">{{ file.name }}</div>
|
|
|
- </template>
|
|
|
+ </template> -->
|
|
|
</van-uploader>
|
|
|
</template>
|
|
|
</van-field>
|
|
|
</van-cell-group>
|
|
|
|
|
|
-
|
|
|
<van-cell-group>
|
|
|
<div class="rowTextArea">
|
|
|
<van-field
|
|
@@ -143,6 +143,8 @@ import { reactive, ref } from "vue";
|
|
|
import personList from "../personList.vue";
|
|
|
import siteInspectionService from "@/api/siteInspection/siteInspectionService";
|
|
|
import tools from "@/api/sys/tools";
|
|
|
+// 图片路径
|
|
|
+import $base from "@/utils/config";
|
|
|
export default {
|
|
|
components: { personList },
|
|
|
setup() {
|
|
@@ -226,22 +228,44 @@ export default {
|
|
|
// 文件上传
|
|
|
let fileList = ref([]);
|
|
|
const afterRead = (file) => {
|
|
|
- fileList.value = [];
|
|
|
// 此时可以自行将文件上传至服务器
|
|
|
new tools()
|
|
|
.uploadFile(file, `csjcqk/siteInspection`)
|
|
|
.then(({ data }) => {
|
|
|
- // window.xm.showToast({
|
|
|
- // message:data.url
|
|
|
- // })
|
|
|
- fileList.value.push("http://localhost:3000"+data.url);
|
|
|
- //siteInspection.value.enclosure = data.url;
|
|
|
+
|
|
|
+ data.name = decodeURIComponent(
|
|
|
+ data.url.substring(
|
|
|
+ data.url.lastIndexOf("/") + 1
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ data.url = `${$base}` + data.url;
|
|
|
+
|
|
|
+
|
|
|
+ //fileList.value[0].url = `${$base}` + fileList.value[0].url;
|
|
|
+ // fileList.value[0].name = decodeURIComponent(
|
|
|
+ // fileList.value[0].url.substring(
|
|
|
+ // fileList.value[0].url.lastIndexOf("/") + 1
|
|
|
+ // )
|
|
|
+ // );
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
});
|
|
|
};
|
|
|
+
|
|
|
+ const fjdelete = (file) => {
|
|
|
+ console.log(file);
|
|
|
+ };
|
|
|
+
|
|
|
// 提交数据
|
|
|
const submit = () => {
|
|
|
//添加保存前判断
|
|
|
|
|
|
+ //保存前附件处理
|
|
|
+ siteInspection.enclosure = data.url;
|
|
|
+
|
|
|
+
|
|
|
new siteInspectionService().save(siteInspection).then((res) => {
|
|
|
if(res.data=="保存场所检查情况成功"){
|
|
|
window.xm.showToast({
|
|
@@ -276,6 +300,7 @@ export default {
|
|
|
// 文件上传
|
|
|
afterRead,
|
|
|
fileList,
|
|
|
+ fjdelete,
|
|
|
submit,
|
|
|
};
|
|
|
},
|
|
@@ -342,4 +367,15 @@ export default {
|
|
|
width: 80%;
|
|
|
top: 50%;
|
|
|
}
|
|
|
+.preview-cover {
|
|
|
+ position: absolute;
|
|
|
+ bottom: 0;
|
|
|
+ box-sizing: border-box;
|
|
|
+ width: 100%;
|
|
|
+ padding: 4px;
|
|
|
+ color: #fff;
|
|
|
+ font-size: 12px;
|
|
|
+ text-align: center;
|
|
|
+ background: rgba(0, 0, 0, 0.3);
|
|
|
+ }
|
|
|
</style>
|