Commit 201207c7 authored by mengwenhao's avatar mengwenhao

fix:商品-门店列表选择/表情符号校验

parent 7ea287f2
......@@ -63,6 +63,7 @@
show-word-limit
v-if="$route.params.operation === 'EDIT'"
v-model="goodsObj.goods_name"
@input="checkHaveExpression"
@blur="checkSameName"
></el-input>
<span v-else>{{ goodsObj.goods_name }}</span>
......@@ -85,9 +86,9 @@
maxlength="50"
show-word-limit
:autosize="{ minRows: 4 }"
v-model="goodsObj.introduce"
v-model="goodsObj.desc"
></el-input>
<span v-else>{{ goodsObj.introduce }}</span>
<span v-else>{{ goodsObj.desc }}</span>
</el-form-item>
</el-form>
</section>
......@@ -235,6 +236,7 @@
</template>
<!-- 门店列表 -->
<el-table
ref="shopListRef"
:data="shopsList"
@selection-change="handleShopsChange"
>
......@@ -242,6 +244,7 @@
type="selection"
width="55"
:selectable="canChooseShop"
aria-checked="true"
>
</el-table-column>
<el-table-column
......@@ -569,18 +572,18 @@
:maxlength="200"
type="textarea"
style="width:100%"
v-model="rejectReason.reason"
v-model.trim="rejectReason.reason"
></el-input>
</el-form-item>
</el-form>
<section style="display:flex;justify-content:center;">
<el-button
type="danger"
@click.stop="onDefault"
@click="onDefault"
>驳回</el-button>
<el-button
type="primary"
@click.stop="rejectVisible = false"
@click="rejectVisible = false"
>取消
</el-button>
</section>
......@@ -623,6 +626,8 @@ import {
import { GOODS_URI } from "../../../../server/config.js";
import filterInput from "../utils/filterInput";
export default {
name: "GoodsDetail",
......@@ -735,6 +740,8 @@ export default {
},
shopsList: [], // 门店列表
shopId: [], // 门店id数组
chooseShopsList: [], // 已选门店列表
shopsCount: 0,
shopCurrentPage: 1, // 门店列表当前页
......@@ -795,10 +802,10 @@ export default {
// 渲染过期时间
this.expirationTime = goods_info.expiration_time;
// 初始化门店id
const shopId = goods_info.sub_shop.map(item => {
this.shopId = goods_info.sub_shop.map(item => {
return item.sub_shop_id;
});
this.shopIds = shopId.join(",");
this.shopIds = this.shopId.join(",");
// 初始化规则开始时间
this.activeStartTime = goods_info.rule_start_time;
// 初始化规则结束时间
......@@ -856,6 +863,16 @@ export default {
return new Date(nowYear, nowMonth, nowDate, Hour, Minute, Second);
},
// 检查输入是否带有表情符号
checkHaveExpression (value) {
if (!filterInput.checkString(value)) {
this.$nextTick(() => {
this.goodsObj.goods_name = "";
});
return this.$message.error("商品名称中不可有表情符号");
}
},
// 获取门店列表
async getShops () {
const query = {
......@@ -868,6 +885,13 @@ export default {
console.log(res);
this.shopsList = res.result;
this.shopsCount = res.count;
this.$nextTick(() => {
this.shopsList.forEach(row => {
if (this.shopId.indexOf(row.sub_shop_id) !== -1) {
this.$refs.shopListRef.toggleRowSelection(row, true);
}
});
});
},
// 门店列表更改时操作
......@@ -880,11 +904,14 @@ export default {
this.shopIds = shopList.join(",");
},
// 是否可选门店
canChooseShop () {
if (this.goodsObj.sub_shop.length === 1) {
return false;
} else {
canChooseShop (row) {
if (
this.goodsObj.sub_shop.length === 0 ||
this.shopIds === row.sub_shop_id
) {
return true;
} else {
return false;
}
},
......@@ -931,10 +958,10 @@ export default {
this.goodsObj.sub_shop = this.goodsObj.sub_shop.filter(item => {
return item.sub_shop_id !== subShopId;
});
const shopIdsList = this.goodsObj.sub_shop.map(item => {
this.shopId = this.goodsObj.sub_shop.map(item => {
return item.sub_shop_id;
});
this.shopIds = shopIdsList.join(",");
this.shopIds = this.shopId.join(",");
},
// 商品列表换页
......@@ -1127,16 +1154,18 @@ export default {
// 审核拒绝
async onDefault () {
console.log(this.rejectReason.reason);
if (this.rejectReason.reason == "") {
return this.$message.error("审核驳回时,驳回原因不能为空");
}
const query = {
goods_spu_id: this.goodsObj.goods_spu_id,
rejected_reason: this.rejectReason.reason
};
console.log(query.rejected_reason);
if (query.rejected_reason !== "0" && !query.rejected_reason) {
return this.$message.error("审核驳回时,审核原因不可为空");
}
const res = await auditReject(query);
if (res.code !== 0) return this.$message.error(res.reason);
if (res.code !== 0) {
return this.$message.error(res.reason);
}
this.$message.warning("审核驳回成功!");
this.$router.replace({ name: "GoodsList" });
},
......@@ -1213,7 +1242,7 @@ export default {
}
if (!query.sub_shop_ids) {
return this.$message.error("请填写门店id");
return this.$message.error("请至少选择一个门店");
}
const res = await editGoods(query);
......
// 检测内容是否带表情符号
function checkString (strings) {
const checkKey = /[^\u0020-\u007E\u00A0-\u00BE\u2E80-\uA4CF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF\u0080-\u009F\u2000-\u201f\u2026\u2022\u20ac\r\n]/g;
if (checkKey.test(strings)) {
return false;
} else {
return true;
};
};
export default { checkString }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment