修复AiUploader

This commit is contained in:
aixianling
2022-02-25 15:34:20 +08:00
parent 7a5edf572d
commit 2bff4ceefc
3 changed files with 19 additions and 18 deletions

View File

@@ -36,7 +36,7 @@ export default {
return this.dictKey ? this.$dict.getDict(this.dict).map(e => ({ return this.dictKey ? this.$dict.getDict(this.dict).map(e => ({
value: e.dictValue, value: e.dictValue,
label: e.dictName label: e.dictName
})) : this.list })) : this.list || []
} }
}, },
data() { data() {
@@ -47,7 +47,7 @@ export default {
} }
}, },
mounted () { mounted() {
this.dict && this.$dict.load(this.dict).then(() => { this.dict && this.$dict.load(this.dict).then(() => {
this.dictKey = this.dict this.dictKey = this.dict
}) })
@@ -56,7 +56,6 @@ export default {
handleConfirm(v) { handleConfirm(v) {
this.selected = v this.selected = v
this.$emit("data", this.selected) this.$emit("data", this.selected)
console.log(v)
this.$emit("input", v[0].value) this.$emit("input", v[0].value)
this.$forceUpdate() this.$forceUpdate()
}, },

View File

@@ -16,10 +16,10 @@
</div> </div>
</template> </template>
<template v-if="!disabled"> <template v-if="!disabled">
<div btn @tap="handleReUpload(i)"> <div class="btn" @tap="handleReUpload(i)">
重新上传 重新上传
</div> </div>
<div btn @tap="remove(i)"> <div class="btn" @tap="remove(i)">
删除 删除
</div> </div>
</template> </template>
@@ -124,8 +124,8 @@ export default {
uni.hideLoading() uni.hideLoading()
} else { } else {
uni.uploadFile({ uni.uploadFile({
url: this.$instance.defaults.baseURL + this.action, url: this.$instance.config.baseURL + this.action,
filePath: img, filePath: img.path,
name: 'file', name: 'file',
header: { header: {
'Content-Type': 'multipart/form-data', 'Content-Type': 'multipart/form-data',
@@ -138,7 +138,7 @@ export default {
this.$emit('data', res.data) this.$emit('data', res.data)
this.$u.toast('上传成功!') this.$u.toast('上传成功!')
if (this.action == '/admin/file/add') { if (this.action == '/admin/file/add') {
this.fileList.push({url: res.data?.split(";")?.[0], id: res.data?.split(";")?.[1]}) this.fileList.push({url: res.data?.[0]?.split(";")?.[0], id: res.data?.[0]?.split(";")?.[1]})
this.$emit('input', [...this.fileList]) this.$emit('input', [...this.fileList])
this.$emit('change', [...this.fileList]) this.$emit('change', [...this.fileList])
} else if (this.action == '/admin/file/add2') { } else if (this.action == '/admin/file/add2') {
@@ -153,6 +153,10 @@ export default {
} else { } else {
this.$u.toast(res.msg) this.$u.toast(res.msg)
} }
},
fail: err => {
console.log(err)
uni.hideLoading()
} }
}) })
} }
@@ -202,8 +206,10 @@ export default {
} }
} }
div[btn] { div.btn {
color: $uni-color-primary; color: $uni-color-primary;
margin-right: 16px;
} }
div:nth-child(4) { div:nth-child(4) {

View File

@@ -19,11 +19,7 @@
<div class="form"> <div class="form">
<em>*</em> <em>*</em>
<label>农产品类型</label> <label>农产品类型</label>
<div class="right" @click="show=true"> <AiSelect class="right" v-model="form.type" dict="agriculturalType"/>
<u-icon name="arrow-right" color="#999999" size="28"></u-icon>
<span class="value" style="color: #999999;font-weight:normal;" v-if="!form.typeName">请选择</span>
<span class="value" style="color: #333;font-weight:normal;" v-else>{{ form.typeName }}</span>
</div>
</div> </div>
</div> </div>
@@ -65,19 +61,19 @@
<div class="btn-wrapper"> <div class="btn-wrapper">
<div class="btn" @click="submit" hover-class="text-hover">提交</div> <div class="btn" @click="submit" hover-class="text-hover">提交</div>
</div> </div>
<u-select v-model="show" :list="$dict.getDict('agriculturalType')" value-name="dictValue"
label-name="dictName" @confirm="confirm"></u-select>
</div> </div>
</template> </template>
<script> <script>
import AiSelect from "../../components/AiSelect/AiSelect";
export default { export default {
name: "agAdd", name: "agAdd",
appName:"发布晒农产品", components: {AiSelect},
appName: "发布晒农产品",
data() { data() {
return { return {
show: false,
form: { form: {
title: "", title: "",
content: "", content: "",