|
@@ -10,7 +10,6 @@
|
|
|
<el-radio :label="2">求购商品</el-radio>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
-
|
|
|
<el-form-item label="商品名称:" prop="name" class="custom-align-right">
|
|
|
<template #label>
|
|
|
<span class="askBox" v-if="form.type_id == 1">
|
|
@@ -23,20 +22,27 @@
|
|
|
<el-input v-model="form.name" autocomplete="off" placeholder="请输入商品标题"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="发布地点:" prop="city_arr_id" class="custom-align-right">
|
|
|
- <el-cascader :key="cascaderKey" v-model="form.city_arr_id" placeholder="发布地区:" :props="cityData" filterable
|
|
|
- clearable></el-cascader>
|
|
|
+ <el-cascader :key="cascaderKey" v-model="form.city_arr_id" placeholder="请选择发布地点" :props="cityData"
|
|
|
+ filterable clearable></el-cascader>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="网站:" prop="website_id" class="custom-align-right" v-if="userType != 10000">
|
|
|
- <el-select v-model="form.website_id" placeholder="请选择网站" filterable clearable>
|
|
|
+ <el-form-item label="站点名称:" prop="website_id" class="custom-align-right" v-if="userType == 10000">
|
|
|
+ <el-select v-model="form.website_id" placeholder="请选择站点名称" filterable clearable>
|
|
|
<el-option v-for="item in websiteOptions" :key="item.value" :label="item.label" :value="item.value">
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
-
|
|
|
- <el-form-item label="导航池名称:" prop="cat_arr_id" class="custom-align-right">
|
|
|
- <el-cascader :key="parentKey" v-model="form.cat_arr_id" placeholder="请选择要绑定的导航池名称" :props="parentData"
|
|
|
+ <el-form-item label="展示名称:" prop="cat_arr_id" class="custom-align-right">
|
|
|
+ <el-cascader :key="parentKey" v-model="form.cat_arr_id" placeholder="请选择要绑定的展示名称" :props="parentData"
|
|
|
filterable clearable></el-cascader>
|
|
|
</el-form-item>
|
|
|
+ <div v-if="user_type == 10000">
|
|
|
+ <el-form-item label="推荐等级:" class="custom-align-right">
|
|
|
+ <el-select v-model="form.level" multiple clearable placeholder="请选择推荐等级.." @change="levelChange">
|
|
|
+ <el-option label="为你精选" :value="1"></el-option>
|
|
|
+ <el-option label="热门产品" :value="2"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
<div v-if="form.type_id == 1">
|
|
|
<el-form-item label="商品单价:" prop="price" class="custom-align-right">
|
|
|
<el-input type="number" v-model="form.price" autocomplete="off" placeholder="请输入商品单价">
|
|
@@ -48,7 +54,6 @@
|
|
|
<el-form-item label="单位:" prop="unit" class="custom-align-right">
|
|
|
<el-input v-model="form.unit" autocomplete="off" placeholder="请输入单位"></el-input>
|
|
|
</el-form-item>
|
|
|
-
|
|
|
<el-form-item label="最小定量:" prop="min" class="custom-align-right">
|
|
|
<el-input v-model="form.min" autocomplete="off" placeholder="请输入最小定量"></el-input>
|
|
|
</el-form-item>
|
|
@@ -58,40 +63,36 @@
|
|
|
<el-form-item label="有效期:" prop="validity" class="custom-align-right">
|
|
|
<el-date-picker v-model="form.validity" type="date" placeholder="选择日期" :disabled="form.islong == 1">
|
|
|
</el-date-picker>
|
|
|
-
|
|
|
- <el-checkbox v-model="form.islong">无期限</el-checkbox>
|
|
|
+ <el-checkbox v-model="form.islong" @change="checked => selectChange(checked)">无期限</el-checkbox>
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
<div v-if="form.type_id == 2">
|
|
|
-
|
|
|
<el-form-item label="截止日期:" prop="validity" class="custom-align-right">
|
|
|
<el-date-picker v-model="form.validity" type="date" placeholder="选择日期" :disabled="form.islong == 1">
|
|
|
</el-date-picker>
|
|
|
- <el-checkbox v-model="form.islong">无期限</el-checkbox>
|
|
|
+ <el-checkbox v-model="form.islong" @change="checked => selectChange(checked)">无期限</el-checkbox>
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
-
|
|
|
<el-form-item label="商品图:" class="custom-align-right" prop="imgurl">
|
|
|
<div class="uploaderBox">
|
|
|
-
|
|
|
<span v-if="imgurl.length > 0" class="uploaded-images">
|
|
|
- <div v-for="(url, index) in imgurl" :key="index" style="display: inline;float: left; width: 150px;;">
|
|
|
-
|
|
|
+ <div v-for="(url, index) in imgurl" :key="index"
|
|
|
+ style="display: inline;float: left; width: 150px; height:140px;">
|
|
|
<img :src="url" class="avatar" style="float: left; margin-right: 10px;">
|
|
|
<div style="position: relative;
|
|
|
- transform: translate(-50%, -50%);
|
|
|
- right: -120px;
|
|
|
- top: -20px;
|
|
|
- background-color: rgba(0, 0, 0, 0.5);
|
|
|
- color: white;
|
|
|
- border-radius: 50%;
|
|
|
- width: 24px;
|
|
|
- height: 24px;
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- justify-content: center;
|
|
|
- cursor: pointer;
|
|
|
- z-index: 10;" @click="deleteImage(index)">
|
|
|
+ transform: translate(-50%, -50%);
|
|
|
+ right: -120px;
|
|
|
+ top: -20px;
|
|
|
+ background-color: rgba(0, 0, 0, 0.5);
|
|
|
+ color: white;
|
|
|
+ border-radius: 50%;
|
|
|
+ width: 24px;
|
|
|
+ height: 24px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ cursor: pointer;
|
|
|
+ z-index: 10;" @click="deleteImage(index)">
|
|
|
<i class="el-icon-delete"></i>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -102,17 +103,30 @@
|
|
|
<img src="@/assets/public/upload/noImage.png">
|
|
|
<div>选择图片</div>
|
|
|
</div>
|
|
|
-
|
|
|
</el-upload>
|
|
|
</div>
|
|
|
</el-form-item>
|
|
|
<div class="imgBox" style="margin-left: 100px ;margin-bottom: 20px; padding-top: -20px;">
|
|
|
最多可上传5张,每张图片大小不能超过500K,推荐上传图片尺寸
|
|
|
宽1000像素 高1000像素。(首张显示为商品头图)</div>
|
|
|
- <el-form-item label="商品关键词:" prop="keyword" class="custom-align-right">
|
|
|
+ <!-- <el-form-item label="商品关键词:" prop="keyword" class="custom-align-right">
|
|
|
<el-input v-model="form.keyword" autocomplete="off" placeholder="请输入商品关键词"></el-input>
|
|
|
+ </el-form-item> -->
|
|
|
+
|
|
|
+ <el-form-item label="商品关键词:" prop="keyword" class="custom-align-right">
|
|
|
+ <template #label>
|
|
|
+ <span class="askBox">
|
|
|
+ 商品关键词:
|
|
|
+ <el-tooltip class="item" effect="dark" content="商品关键词,如:三农市场网、全国三农、信息一体化。" placement="top">
|
|
|
+ <i class="el-icon-question"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ <tagInput :initialTags="tags" @tags-updated="updateTags"></tagInput>
|
|
|
</el-form-item>
|
|
|
|
|
|
+
|
|
|
+
|
|
|
<el-form-item label="商品描述:" prop="description" class="custom-align-right">
|
|
|
<el-input v-model="form.description" maxlength="300" autocomplete="off" placeholder="请输入商品描述"
|
|
|
type="textarea" :rows="10"></el-input>
|
|
@@ -160,6 +174,8 @@
|
|
|
import { getWebSiteId, getUseType } from '@/utils/auth'
|
|
|
//表格标题
|
|
|
import tableTitle from './components/tableTitle';
|
|
|
+//引入tag标签组件
|
|
|
+import tagInput from '../../components/InputTag/index.vue';
|
|
|
//引入公用样式
|
|
|
import '@/styles/global.less';
|
|
|
//格式化时间
|
|
@@ -171,7 +187,8 @@ import myEditor from '../../components/edit/myEditor.vue';
|
|
|
export default {
|
|
|
components: {
|
|
|
tableTitle,
|
|
|
- myEditor
|
|
|
+ myEditor,
|
|
|
+ tagInput
|
|
|
},
|
|
|
data() {
|
|
|
//0.全局操作 start ------------------------------------------------------------>
|
|
@@ -211,7 +228,8 @@ export default {
|
|
|
tableDivTitle: "添加商品",
|
|
|
searchCascaderKey: 0, //列表缓存key
|
|
|
// imgurl: ['http://192.168.1.127:9501/image/20250227/1740674706184955.jpg', 'http://192.168.1.127:9501/image/20250227/1740674706184955.jpg'],//图片路径
|
|
|
- website_id: 2,
|
|
|
+ website_id: "",
|
|
|
+ tags: [],//标签数组
|
|
|
|
|
|
//提交表单
|
|
|
form: {
|
|
@@ -221,10 +239,11 @@ export default {
|
|
|
city_arr_id: [],//行政区划
|
|
|
city_id: '',//城市id
|
|
|
cat_arr_id: '',//导航池名称
|
|
|
- website_id: 2,
|
|
|
+ website_id: "",
|
|
|
catid: "",
|
|
|
cat_arr_id: "",
|
|
|
name: "",
|
|
|
+ level: [],//推荐等级
|
|
|
price: "",
|
|
|
unit: "",
|
|
|
min: null,
|
|
@@ -418,8 +437,6 @@ export default {
|
|
|
this.getMainData();
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
-
|
|
|
// 监听路由参数中的 id 变化,若变化则更新页面状态并获取数据
|
|
|
// '$route.query.id': function (newVal, oldVal) {
|
|
|
// console.log('当前 id:', newVal, '旧的 id:', oldVal);
|
|
@@ -455,9 +472,12 @@ export default {
|
|
|
this.$store.dispatch('public/getInfo').then(res => {
|
|
|
console.log(res)
|
|
|
this.userType = res.data.type_id;
|
|
|
- if (this.userType == 10000) {
|
|
|
- this.form.website_id = getWebSiteId() !== undefined ? getWebSiteId() : 2;;
|
|
|
+ this.user_type = res.data.type_id;
|
|
|
+
|
|
|
+ if (this.userType != 10000) {
|
|
|
+ this.form.website_id = getWebSiteId()
|
|
|
}
|
|
|
+
|
|
|
//if(res.data.type_id==10000){}//管理员
|
|
|
//if(res.data.type_id==4){}//调研员
|
|
|
//个人会员=1 政务会员=2 企业会员=3 调研员=4 管理员=10000 游客=20000
|
|
@@ -504,15 +524,23 @@ export default {
|
|
|
},
|
|
|
//1.2 提交表单
|
|
|
addToServe() {
|
|
|
+
|
|
|
+ this.form.website_id = getWebSiteId();
|
|
|
+ console.log("提交时获取网站id:",this.form.website_id)
|
|
|
//先进行验证
|
|
|
this.$refs.form.validate(valid => {
|
|
|
-
|
|
|
console.log(this.form.validity, 'this.form.validity-----------------')
|
|
|
if (this.form.islong == 1 && (this.form.validity == null || this.form.validity == '')) {
|
|
|
this.form.validity = '1970-01-01 00:00:00';
|
|
|
}
|
|
|
console.log(this.form.validity, 'this.form.validity-----------------')
|
|
|
if (valid) {
|
|
|
+ //如果推荐等级为空,则设置为0
|
|
|
+ if (this.form.level == "" || this.form.level == "[0]") {
|
|
|
+ this.form.level = "[0]";
|
|
|
+ } else {
|
|
|
+ this.form.level = JSON.stringify(this.form.level);
|
|
|
+ }
|
|
|
if (this.form.validity) {
|
|
|
console.log(this.form.validity, 'p0------------------')
|
|
|
this.form.validity = formatLocalDate(this.form.validity);
|
|
@@ -599,10 +627,8 @@ export default {
|
|
|
this.parentKey += 1; // 触发级联选择器重新加载
|
|
|
this.loadCascaderPath(this.form.cat_arr_id); // 加载路径数据
|
|
|
//回显推荐等级
|
|
|
-
|
|
|
this.form.imgurl = Array.isArray(res.data.imgurl) ? res.data.imgurl : JSON.parse(res.data.imgurl);
|
|
|
this.imgurl = Array.isArray(res.data.imgurl) ? res.data.imgurl : JSON.parse(res.data.imgurl);
|
|
|
- this.form.keyword = res.data.keyword;
|
|
|
this.form.type_id = res.data.type_id;
|
|
|
this.form.website_id = res.data.website_id;
|
|
|
this.form.catid = res.data.catid;
|
|
@@ -613,6 +639,7 @@ export default {
|
|
|
this.form.islong = res.data.islong == 1 ? true : false;
|
|
|
this.form.validity = res.data.validity;
|
|
|
this.form.keyword = res.data.keyword;
|
|
|
+ this.tags = res.data.keyword ? res.data.keyword.split(",") : [];
|
|
|
this.form.description = res.data.description;
|
|
|
//回显编辑器内容
|
|
|
this.$nextTick(() => {
|
|
@@ -625,6 +652,12 @@ export default {
|
|
|
this.form.email = res.data.email;
|
|
|
this.form.postal = res.data.postal;
|
|
|
this.form.address = res.data.address;
|
|
|
+ this.form.level = res.data.level;
|
|
|
+ if (res.data.level == "[]" || res.data.level == "") {
|
|
|
+ this.form.level = [];
|
|
|
+ } else {
|
|
|
+ this.form.level = JSON.parse(res.data.level);
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
async loadCascaderPath(path) {
|
|
@@ -670,6 +703,12 @@ export default {
|
|
|
this.$refs.form.validate(valid => {
|
|
|
|
|
|
if (valid) {
|
|
|
+ //如果推荐等级为空,则设置为0
|
|
|
+ if (this.form.level == "" || this.form.level == "[]" || this.form.level == null) {
|
|
|
+ this.form.level = "[]";
|
|
|
+ } else {
|
|
|
+ this.form.level = JSON.stringify(this.form.level);
|
|
|
+ }
|
|
|
if (this.form.validity) {
|
|
|
console.log(this.form.validity, 'p0------------------')
|
|
|
this.form.validity = formatLocalDate(this.form.validity);
|
|
@@ -720,7 +759,24 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ //推荐等级选择
|
|
|
+ levelChange(value) {
|
|
|
+ this.form.level = value;
|
|
|
+ },
|
|
|
//跳转操作 end ------------------------------------------------------------>
|
|
|
+ //商品关键词
|
|
|
+ updateTags(newTags) {
|
|
|
+ // this.foem.seo_keywords = newTags;
|
|
|
+ this.tags = newTags;
|
|
|
+ this.form.keyword = newTags.join(',');
|
|
|
+ },
|
|
|
+ selectChange(checked){
|
|
|
+ if(checked==true){
|
|
|
+ this.form.validity = '1970-01-01 00:00:00';
|
|
|
+ }else{
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
watch: {
|
|
|
'form.type_id': {
|
|
@@ -780,6 +836,7 @@ export default {
|
|
|
},
|
|
|
immediate: true // 立即执行一次
|
|
|
}
|
|
|
+
|
|
|
},
|
|
|
mounted() {
|
|
|
this.user_type = getUseType();
|
|
@@ -845,4 +902,33 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+::v-deep .el-upload {
|
|
|
+ display: inline-block;
|
|
|
+ text-align: center;
|
|
|
+ cursor: pointer;
|
|
|
+ outline: none;
|
|
|
+ border: 1px solid #ccc;
|
|
|
+ padding: 26px 20px;
|
|
|
+ border-radius: 10px;
|
|
|
+ width: 140px;
|
|
|
+ height: 140px;
|
|
|
+}
|
|
|
+
|
|
|
+::v-deep .avatar {
|
|
|
+ width: 140px;
|
|
|
+ height: 140px;
|
|
|
+ display: block;
|
|
|
+ border: 1px solid #ccc;
|
|
|
+ padding: 5px;
|
|
|
+ border-radius: 10px;
|
|
|
+ box-sizing: border-box;
|
|
|
+}
|
|
|
+
|
|
|
+::v-deep .el-checkbox {
|
|
|
+ margin-left: 20px;
|
|
|
+}
|
|
|
+.imgBox{
|
|
|
+ color: #999;
|
|
|
+}
|
|
|
+
|
|
|
//执行v-deep穿透scope选择器 end------------------------------------------------------------>*/</style>
|