修改上传逻辑

This commit is contained in:
liaozetao
2023-11-20 11:58:10 +08:00
parent 518842aca2
commit 395e3917f8
2 changed files with 60 additions and 59 deletions

View File

@@ -45,7 +45,8 @@
<el-table-column align="center" label="操作" width="200">
<template v-slot="scope">
<el-button @click="editClick(scope.row)" class="primary" type="primary" size="default">编辑</el-button>
<el-button @click="delClick(scope.row)" class="danger" type="danger" size="default" v-if="scope.row.skipType != 1">删除</el-button>
<el-button @click="delClick(scope.row)" class="danger" type="danger" size="default"
v-if="scope.row.skipType != 1">删除</el-button>
</template>
</el-table-column>
</el-table>
@@ -64,27 +65,28 @@
<div style="margin-bottom: 25px">
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">icon</span>
<input type="hidden" class="form-control" name="icon" v-model="resource.icon" />
<img :src="resource.icon" style="width:120px;"/>
<input type="file" style="width: 26%; display: inline-block;" id="iconFile" name="iconFile"/>
<img :src="resource.icon" style="width:120px;" />
<input type="file" style="width: 26%; display: inline-block;" id="iconFile" name="iconFile" />
</div>
<div style="margin-bottom: 25px">
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label"></span>
<button class="btn btn-success col-sm-4" type="button" id="iconUploadBtn">上传</button>
<span class="btn col-sm-4" id="iconUploadInfo" style="color:red;"></span>
<button class="btn btn-success col-sm-4" type="button" id="iconUploadBtn" @click="uploadIcon()">上传</button>
<span class="btn col-sm-4" id="iconUploadInfo" style="color:red;"></span>
</div>
<div style="margin-bottom: 25px;margin-top: 70px;">
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">跳转位置</span>
<el-select v-model="resource.skipType" style="width: 75%" placeholder="请选择">
<el-option v-for="item in options" :key="item.value" :label="item.label"
:value="item.value"></el-option>
</el-select>
<el-option v-for="item in options" :key="item.value" :label="item.label"
:value="item.value"></el-option>
</el-select>
</div>
<div style="margin-bottom: 25px" v-if="resource.skipType == 1">
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">资源编码</span>
<el-input v-model="resource.code" style="width: 75%" class="input" :placeholder="请输入资源编码"></el-input>
</div>
<div style="margin-bottom: 25px" v-if="resource.skipType == 2 || resource.skipType == 3">
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">{{ resource.skipType == 2 ? "跳转链接" :
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">{{ resource.skipType
== 2 ? "跳转链接" :
(resource.skipType == 3 ? "跳转房间" : "") }}</span>
<el-input v-model="resource.skipContent" style="width: 75%" class="input"
:placeholder="[resource.skipType == 2 ? '请输入跳转链接' : (resource.skipType == 3 ? '请输入房间ID' : '')]"></el-input>
@@ -92,38 +94,39 @@
<div style="margin-bottom: 25px" v-if="resource.skipType == 2">
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">切换banner</span>
<input type="hidden" class="form-control" name="avatar" v-model="resource.url" />
<img :src="resource.url" style="width:120px;"/>
<input type="file" style="width: 26%; display: inline-block;" id="urlFile" name="urlFile"/>
<img :src="resource.url" style="width:120px;" />
<input type="file" style="width: 26%; display: inline-block;" id="urlFile" name="urlFile" />
</div>
<div style="margin-bottom: 25px">
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label"></span>
<button class="btn btn-success col-sm-4" type="button" id="urlUploadBtn">上传</button>
<span class="btn col-sm-4" id="urlUploadInfo" style="color:red;"></span>
<button class="btn btn-success col-sm-4" type="button" id="urlUploadBtn" @click="uploadUrl()">上传</button>
<span class="btn col-sm-4" id="urlUploadInfo" style="color:red;"></span>
</div>
<div style="margin-bottom: 25px;margin-top: 70px;">
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">生效时间</span>
<el-date-picker v-model="resource.startTime" type="datetime" placeholder="选择日期时间">
</el-date-picker>
</el-date-picker>
</div>
<div style="margin-bottom: 25px">
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">失效时间</span>
<el-date-picker v-model="resource.endTime" type="datetime" placeholder="选择日期时间">
</el-date-picker>
</el-date-picker>
</div>
<div style="margin-bottom: 25px">
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">排序</span>
<el-input v-model="resource.seqNo" style="width: 75%" class="input" placeholder="请输入排序"></el-input>
</div>
<div style="margin-bottom: 25px" v-for="(rule, index) in rules" :key="rule" :index="index">
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">{{ rule.ruleName }}</span>
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label">{{ rule.ruleName
}}</span>
<el-input v-model="resource.ruleValue[rule.ruleCode]" style="width: 75%" class="input"
:placeholder="rule.description" v-if="rule.ruleKind != 'IN'"></el-input>
<el-select v-model="resource.ruleValue[rule.ruleCode]" style="width: 75%" placeholder="请选择"
v-if="rule.ruleKind == 'IN'">
<el-option label="全部" :value="''"></el-option>
<el-option v-for="value in rule.ruleValue.split(',')" :key="value" :label="value"
:value="value"></el-option>
</el-select>
<el-select v-model="resource.ruleValue[rule.ruleCode]" style="width: 75%" placeholder="请选择"
v-if="rule.ruleKind == 'IN'">
<el-option label="全部" :value="''"></el-option>
<el-option v-for="value in rule.ruleValue.split(',')" :key="value" :label="value"
:value="value"></el-option>
</el-select>
</div>
<template #footer>
<span class="dialog-footer">
@@ -201,34 +204,34 @@ export default {
return {};
},
created() {
this.init();
this.getRule();
this.getData();
},
methods: {
init() {
this.$nextTick(function () {
let $this = this;
$('#iconUploadBtn').click(function () {
console.log('iconUploadBtn');
uploadFile('iconFile').then(res => {
console.log(res);
if (res.path) {
$this.resource.icon = res.path;
$('#iconUploadInfo').val('上传成功');
}
});
uploadIcon() {
let $this = this;
$('#iconUploadBtn').click(function () {
console.log('iconUploadBtn');
uploadFile('iconFile').then(res => {
console.log(res);
if (res.path) {
$this.resource.icon = res.path;
$('#iconUploadInfo').val('上传成功');
}
});
});
},
uploadUrl() {
let $this = this;
$('#urlUploadBtn').click(function () {
console.log('urlUploadBtn');
uploadFile('urlFile').then(res => {
console.log(res);
if (res.path) {
$this.resource.url = res.path;
$('#urlUploadInfo').val('上传成功');
}
});
$('#urlUploadBtn').click(function () {
console.log('urlUploadBtn');
uploadFile('urlFile').then(res => {
console.log(res);
if (res.path) {
$this.resource.url = res.path;
$('#urlUploadInfo').val('上传成功');
}
});
});
});
},
getRule() {
@@ -274,7 +277,7 @@ export default {
}
if (endTime) {
v['endTime'] = new Date(endTime).format("yyyy-MM-dd hh:mm:ss");
}
}
return v;
});
console.log(this.tableData);

View File

@@ -56,7 +56,7 @@
</div>
<div style="margin-bottom: 25px">
<span style="display: inline-block; margin-right: 20px" class="col-sm-2 control-label"></span>
<button class="btn btn-success col-sm-4" type="button" id="urlUploadBtn">上传</button>
<button class="btn btn-success col-sm-4" type="button" id="urlUploadBtn" @click="uploadUrl()">上传</button>
<span class="btn col-sm-4" id="urlUploadInfo" style="color:red;"></span>
</div>
<div style="margin-bottom: 25px;margin-top: 70px;">
@@ -169,22 +169,20 @@ export default {
return {};
},
created() {
this.init();
this.getRule();
this.getData();
},
methods: {
init() {
this.$nextTick(function () {
let $this = this;
$('#urlUploadBtn').click(function () {
uploadFile('urlFile').then(res => {
if (res.path) {
$this.resource.url = res.path;
$('#urlUploadInfo').val('上传成功');
}
});
});
uploadUrl() {
$('#urlUploadBtn').click(function () {
console.log('urlUploadBtn');
uploadFile('urlFile').then(res => {
console.log(res);
if (res.path) {
$this.resource.url = res.path;
$('#urlUploadInfo').val('上传成功');
}
});
});
},
getRule() {