first commit
This commit is contained in:
@@ -0,0 +1,424 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card shadow="never">
|
||||
<el-form ref="form">
|
||||
|
||||
<el-card v-for="(s,idx) in subject" :key="s.id" class="item" shadow="hover">
|
||||
<!-- <el-form-item :label="(s.subjectType==='radio'?'(单选)':'(多选)')+ (idx+1)+'.'" prop="subjectName">-->
|
||||
<el-form-item label="" prop="subjectName">
|
||||
<div class="s-title-wrap">
|
||||
<el-row align="middle" style="width: 100%" type="flex">
|
||||
<el-col :xl="20"
|
||||
style="border: 1px dashed rgb(217, 217, 217);border-radius:6px;display: flex;align-items: center;">
|
||||
<el-input v-model="s.subjectName" class="text-input"
|
||||
data-type="subject"></el-input>
|
||||
</el-col>
|
||||
<el-col :xl="2" style="text-align: center"></el-col>
|
||||
<!-- <el-col :xl="2" style="text-align: center">
|
||||
<div class="option-delete">
|
||||
<el-button circle
|
||||
icon="el-icon-delete"
|
||||
size="mini" type="danger"
|
||||
@click="subject.splice(idx,1)"></el-button>
|
||||
</div>
|
||||
</el-col>-->
|
||||
</el-row>
|
||||
</div>
|
||||
<div class="s-options-list" style="margin-top: 10px;">
|
||||
<el-table :data="s.options" border>
|
||||
<el-table-column
|
||||
align="center"
|
||||
header-align="center"
|
||||
label="类型"
|
||||
width="150"
|
||||
>
|
||||
<template slot-scope="{row}">
|
||||
<el-select v-model="row.optionType" placeholder="请选择"
|
||||
@change="optionTypeChange(row)">
|
||||
<el-option
|
||||
|
||||
v-for="item in typeOptions"
|
||||
:key="item"
|
||||
:label="item"
|
||||
:value="item">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
header-align="center"
|
||||
label="福利名称"
|
||||
>
|
||||
<template slot-scope="{row}">
|
||||
<div
|
||||
style="border: 1px dashed rgb(217, 217, 217);border-radius:6px;display: flex;align-items: center;padding-left: 10px;">
|
||||
<i v-if="s.subjectType==='radio'" class="fa fa-circle-o"
|
||||
style="cursor: pointer"></i>
|
||||
<i v-else-if="s.subjectType==='checkBox'" class="fa fa-square-o"
|
||||
style="cursor: pointer"></i>
|
||||
|
||||
<template v-if="row.optionType==='套餐'">
|
||||
<el-input v-model="row.optionName" autosize
|
||||
class="text-input"
|
||||
data-type="option"
|
||||
></el-input>
|
||||
</template>
|
||||
|
||||
<template v-if="row.optionType==='提货券'">
|
||||
<el-select v-model="row.optionNameId" placeholder="请选择"
|
||||
@change="optionNameIdChange(row)" style="width: 100%">
|
||||
<el-option
|
||||
|
||||
v-for="item in shoppingTypeOptions"
|
||||
:key="item.id"
|
||||
:disabled="item.disabled"
|
||||
:label="item.shoppingName"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column width="120px" label="所属供应商">
|
||||
<template slot-scope="{row}">
|
||||
{{ row.shoppingName ? row.shoppingName : '暂无' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="排序" width="120px">
|
||||
<template slot-scope="{row}">
|
||||
<div
|
||||
style="border: 1px dashed rgb(217, 217, 217);border-radius:6px;display: flex;align-items: center;padding-left: 10px;">
|
||||
<el-input v-model="row.optionSort" autosize
|
||||
class="text-input"
|
||||
data-type="option"
|
||||
></el-input>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="图片" width="120">
|
||||
<template slot-scope="{row,$index}">
|
||||
<image-upload :height="100"
|
||||
:width="100"
|
||||
:limit="1"
|
||||
:file-type="['png','jpg']"
|
||||
:file-size="0.2"
|
||||
:size="[500,200]"
|
||||
v-model="row.imgUrl"></image-upload>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="说明" width="100px">
|
||||
<template slot-scope="scope">
|
||||
<el-link type="primary"
|
||||
@click="openDescRichText(scope.row.description,idx,scope.$index)">编辑说明
|
||||
</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
header-align="center"
|
||||
label="默认选择"
|
||||
width="100px">
|
||||
<template slot-scope="{row,$index}">
|
||||
<el-checkbox v-model="row.isSystemDefault"
|
||||
@change="(val,event)=>{systemDefaultChange(idx,$index,val)}"
|
||||
></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column
|
||||
align="center"
|
||||
header-align="center"
|
||||
label="默认选择几个"
|
||||
width="100px">
|
||||
<template slot-scope="{row,$index}">
|
||||
<el-input v-model="row.defaultSelectNum"></el-input>
|
||||
</template>
|
||||
</el-table-column>-->
|
||||
<el-table-column label="没选系统自动分配" width="150px">
|
||||
<template slot-scope="{row,$index}">
|
||||
<el-checkbox v-model="row.isDefaultOption"
|
||||
@change="(val,event)=>{defaultOptionChange(idx,$index,val)}"
|
||||
></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="操作" width="100px">
|
||||
<template slot-scope="{row,$index}">
|
||||
<div class="option-delete">
|
||||
<el-button circle
|
||||
icon="el-icon-delete"
|
||||
size="mini" type="danger"
|
||||
@click="deleteRow(s.options,row,$index)"></el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="s-operation">
|
||||
<el-button size="small" type="primary"
|
||||
@click="s.options.push({optionType:'套餐',optionNameId:'',optionName:'福利'+(s.options.length+1),optionSort:s.options.length+1,imgUrl:null,isDefaultOption:false,isSystemDefault:false})">
|
||||
添加福利
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-card>
|
||||
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-dialog
|
||||
:close-on-click-modal="false"
|
||||
:visible.sync="richTextDialog"
|
||||
title="编辑说明"
|
||||
:append-to-body="true"
|
||||
width="60%">
|
||||
<text-editor v-model="descRichTextContent"></text-editor>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="richTextDialog = false">取 消</el-button>
|
||||
<el-button type="primary" @click="saveRichText">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
let questionRichTextEditor = null
|
||||
|
||||
module.exports = {
|
||||
components: {
|
||||
vuedraggable: window.vuedraggable,
|
||||
},
|
||||
watch: {
|
||||
subject(val) {
|
||||
}
|
||||
},
|
||||
props: {
|
||||
subject: {
|
||||
type: Array,
|
||||
default: []
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
files: [],
|
||||
typeOptions: ["套餐", "提货券"],
|
||||
shoppingTypeOptions: null,
|
||||
richTextDialog: false,
|
||||
subjectIndex: 0,
|
||||
optionIndex: 0,
|
||||
imgPopover: false,
|
||||
idx: null,
|
||||
oidx: null,
|
||||
|
||||
//富文本内容
|
||||
descRichTextContent: ''
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
deleteRow(options, row, index) {
|
||||
options.splice(index, 1)
|
||||
const shoppingTypeOption = this.shoppingTypeOptions.find(v => v.id === row.optionNameId)
|
||||
shoppingTypeOption.disabled = false
|
||||
},
|
||||
optionTypeChange(row) {
|
||||
this.optionNameIdChange()
|
||||
row.optionNameId = null
|
||||
row.optionName = null
|
||||
},
|
||||
optionNameIdChange(row) {
|
||||
if (row) {
|
||||
row.optionName = this.shoppingTypeOptions.find(v => v.id === row.optionNameId).shoppingName
|
||||
}
|
||||
const optionNameIds = this.subject[0].options.map(v => v.optionNameId)
|
||||
this.shoppingTypeOptions.forEach(v => {
|
||||
v.disabled = optionNameIds.includes(v.id)
|
||||
})
|
||||
this.$forceUpdate()
|
||||
},
|
||||
addSubject(type) {
|
||||
let subject = {
|
||||
subjectName: '题目' + (this.subject.length + 1),
|
||||
subjectType: type,
|
||||
options: [
|
||||
{optionName: '选项一', imgUrl: null},
|
||||
{optionName: '选项一', imgUrl: null}
|
||||
]
|
||||
}
|
||||
this.subject.push(subject)
|
||||
},
|
||||
defaultOptionChange(idx, oidx, val) {
|
||||
const subject = this.subject[idx]
|
||||
const {subjectType} = subject
|
||||
if (val) {
|
||||
// subject.options.forEach(v => v.isDefaultOption = false)
|
||||
subject.options[oidx].isDefaultOption = true
|
||||
}
|
||||
},
|
||||
systemDefaultChange(idx, oidx, val) {
|
||||
const subject = this.subject[idx]
|
||||
const {subjectType} = subject
|
||||
if (val) {
|
||||
subject.options.forEach(v => v.isSystemDefault = false)
|
||||
subject.options[oidx].isSystemDefault = true
|
||||
}
|
||||
},
|
||||
validate(fn) {
|
||||
if (this._validate()) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
||||
},
|
||||
_validate() {
|
||||
return this.subject.some(v => {
|
||||
if (!v.subjectName) return true
|
||||
return v.options.some(x => {
|
||||
if (!x.optionName) return true
|
||||
})
|
||||
})
|
||||
},
|
||||
openDescRichText(richText, sIdx, oIdx) {
|
||||
this.descRichTextContent = richText
|
||||
this.richTextDialog = true
|
||||
this.subjectIndex = sIdx
|
||||
this.optionIndex = oIdx
|
||||
},
|
||||
saveRichText() {
|
||||
this.subject[this.subjectIndex]['options'][this.optionIndex].description = this.descRichTextContent
|
||||
this.richTextDialog = false
|
||||
},
|
||||
async getShoppingType() {
|
||||
const resp = await $.get("/platform/shoppingType/apply/getShoppingType", {typeName: "商超"})
|
||||
this.shoppingTypeOptions = resp.data
|
||||
},
|
||||
doCopy(row) {
|
||||
const input = document.createElement('input')
|
||||
input.value = APP_DOMAIN + FILE_STREAM_PREVIEW_ADDRESS + "?id=" + row.id // 设置复制内容
|
||||
document.body.appendChild(input) // 添加临时实例
|
||||
input.select() // 选择实例内容
|
||||
document.execCommand('Copy') // 执行复制
|
||||
document.body.removeChild(input) // 删除临时实例
|
||||
this.$message.success('复制成功!')
|
||||
},
|
||||
|
||||
},
|
||||
created() {
|
||||
this.getShoppingType()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.avatar-uploader .el-upload {
|
||||
border: 1px dashed #d9d9d9;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
/* width: 40px;
|
||||
height: 40px;*/
|
||||
/*line-height: 40px;*/
|
||||
}
|
||||
|
||||
.avatar-uploader .el-upload:hover {
|
||||
border-color: #409EFF;
|
||||
}
|
||||
|
||||
.avatar-uploader-icon {
|
||||
font-size: 14px;
|
||||
color: #8c939d;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
.el-upload el-upload--text {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 100px;
|
||||
height: 80px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/*被拖拽对象的样式*/
|
||||
.item {
|
||||
padding: 6px;
|
||||
background-color: #FFF;
|
||||
border: solid 1px #eee;
|
||||
margin-bottom: 10px;
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.item:hover {
|
||||
/*background-color: #f1f1f1;*/
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
/*选中样式*/
|
||||
.chosen {
|
||||
border: solid 1px #3089dc !important;
|
||||
}
|
||||
|
||||
.s-title-wrap {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
word-break: break-word;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
|
||||
.s-operation {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: start;
|
||||
padding: 5px 0;
|
||||
}
|
||||
|
||||
.s-operation > span {
|
||||
display: flex;
|
||||
height: 22px;
|
||||
cursor: pointer;
|
||||
color: #2672ff;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
|
||||
.option-delete {
|
||||
width: 80px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.s-operation i {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.text-input > input, .text-input > textarea {
|
||||
resize: none;
|
||||
overflow: hidden;
|
||||
/*border: 1px dashed rgb(217, 217, 217);*/
|
||||
border: none;
|
||||
}
|
||||
|
||||
.avatar-delete {
|
||||
font-size: 20px;
|
||||
color: red;
|
||||
}
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user