mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2025-12-19 17:35:53 +08:00
添加注释,测试功能,选择部门组件报错,会员详情积分字段展示错误,售后原因添加标识判断是新增还是编辑
This commit is contained in:
@@ -1,633 +0,0 @@
|
||||
<template>
|
||||
<Collapse v-model="open_panel">
|
||||
<Panel name="1">
|
||||
规格名称
|
||||
<div slot="content" class="sku-item-content">
|
||||
<Form :model="skuForm" @submit.native.prevent style="width:100%;">
|
||||
<div v-for="(item, $index) in skuInfo" :key="$index" class="sku_value">
|
||||
<Card :bordered="true" style="margin: 15px 0;">
|
||||
<FormItem label="规格名:" class="sku-item-content-name">
|
||||
<AutoComplete
|
||||
style="width: 150px;"
|
||||
v-model="item.name"
|
||||
:maxlength="30"
|
||||
:data="skuKey"
|
||||
placeholder="请输入规格项名称"
|
||||
:filter-method="filterMethod"
|
||||
@on-change="skuItemChange(item.name,$index)"
|
||||
@keyup.enter.native="editSkuItem(item, $index)"
|
||||
>
|
||||
<!-- @on-focus="getActiveSkuItem(index, $index ,item, val)"
|
||||
@on-blur="editSkuItem(item, $index)"
|
||||
on-change 变更
|
||||
on-focus 聚焦时触发 event
|
||||
on-blur 失焦时触发
|
||||
keyup.enter.native 回车时 -->
|
||||
</AutoComplete>
|
||||
<Button
|
||||
type="error"
|
||||
style="margin-left: 10px;"
|
||||
@click="handleCloseSkuItem($index)"
|
||||
>删除</Button>
|
||||
<Checkbox
|
||||
v-if="$index === 0"
|
||||
style="padding: 0px 0px 0px 30px;"
|
||||
v-model="checkedImage"
|
||||
@on-change="handleChangeImage"
|
||||
>规格图片</Checkbox>
|
||||
</FormItem>
|
||||
|
||||
<FormItem label="规格值:" class="sku-item-content-value">
|
||||
<!--规格值文本列表-->
|
||||
<div
|
||||
v-for="(val, index) in item.spec_values"
|
||||
:key="index"
|
||||
style="padding: 0px 20px 10px 0px;float: left"
|
||||
>
|
||||
<div style="display:inline-block;">
|
||||
<AutoComplete
|
||||
style="width: 150px; float: left"
|
||||
v-model="val.value"
|
||||
:maxlength="30"
|
||||
:data="skuValue"
|
||||
placeholder="请输入规格值名称"
|
||||
:filter-method="filterMethod"
|
||||
@on-change="skuValueChange(val.value,$index)"
|
||||
@on-focus="editSkuIValue($index)"
|
||||
@keyup.enter.native="editSkuIValue(item, val, $index, index)"
|
||||
></AutoComplete>
|
||||
<Button
|
||||
type="error"
|
||||
style="float: left;margin-left: 10px"
|
||||
@click="handleCloseSkuValue($index, index)"
|
||||
>删除</Button>
|
||||
</div>
|
||||
<div>
|
||||
<upload-pic-thumb
|
||||
style="text-align: left;"
|
||||
v-show="$index === 0 && checkedImage"
|
||||
v-model="val.spec_image" v-on:change="thumbChange" :multiple="false" v-on:uploadchange="uploadchange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div style="float: left">
|
||||
<Button type="primary" @click="addSpec($index, item)">添加规格值</Button>
|
||||
</div>
|
||||
</FormItem>
|
||||
</Card>
|
||||
</div>
|
||||
</Form>
|
||||
<Button type="primary" size="mini" @click="addSkuItem">添加规格项目</Button>
|
||||
</div>
|
||||
</Panel>
|
||||
<Panel name="2">
|
||||
规格详细
|
||||
<div slot="content">
|
||||
<div slot="content">
|
||||
<Table
|
||||
:columns="skuTableColumn"
|
||||
:data="skuTableData"
|
||||
style="width: 100%;.ivu-table-overflowX{ overflow-x: hidden;}"
|
||||
:span-method="handleSpan"
|
||||
>
|
||||
<template slot-scope="{ row }" slot="sn">
|
||||
<Input
|
||||
v-model="row.sn"
|
||||
placeholder="请输入货号"
|
||||
@on-change="updateSkuTable(row,'sn')"
|
||||
@on-focus="updateSkuTable(row,'sn')"
|
||||
@on-blur="updateSkuTable(row,'sn')"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template slot-scope="{ row }" slot="weight">
|
||||
<Input
|
||||
v-model="row.weight"
|
||||
placeholder="请输入重量"
|
||||
@on-change="updateSkuTable(row,'weight')"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template slot-scope="{ row }" slot="quantity">
|
||||
<Input
|
||||
v-model="row.quantity"
|
||||
placeholder="请输入库存"
|
||||
@on-change="updateSkuTable(row,'quantity')"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template slot-scope="{ row }" slot="cost">
|
||||
<Input
|
||||
v-model="row.cost"
|
||||
placeholder="请输入成本价"
|
||||
@on-change="updateSkuTable(row,'cost')"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template slot-scope="{ row }" slot="price">
|
||||
<Input
|
||||
v-model="row.price"
|
||||
placeholder="请输入成本价"
|
||||
@on-change="updateSkuTable(row,'price')"
|
||||
/>
|
||||
</template>
|
||||
</Table>
|
||||
</div>
|
||||
</div>
|
||||
</Panel>
|
||||
</Collapse>
|
||||
</template>
|
||||
<script>
|
||||
import { regular } from "@/utils";
|
||||
import uploadPicThumb from "../lili/upload-pic-thumb.vue";
|
||||
import cloneObj from "@/utils/index";
|
||||
export default {
|
||||
name: "goodsSku",
|
||||
components: {
|
||||
uploadPicThumb
|
||||
},
|
||||
props: {
|
||||
open_panel: {
|
||||
type: [String, Number],
|
||||
default: false
|
||||
},
|
||||
/** 是否自动生成货号 */
|
||||
productSn: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
/** 当前商品编号 */
|
||||
goodsSn: {
|
||||
type: [String, Number],
|
||||
default: ['', 0]
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
/** 请求数据*/
|
||||
skuData: [],
|
||||
|
||||
/** 当前可选择的 规格名称*/
|
||||
skuKey: [],
|
||||
|
||||
/** 当前可选择的 规格值*/
|
||||
skuValue: [],
|
||||
|
||||
/** 表单数据*/
|
||||
skuForm: {},
|
||||
/** 表格头 */
|
||||
skuTableColumn: [],
|
||||
/** 表格数据 */
|
||||
skuTableData: [
|
||||
{
|
||||
sn: '',
|
||||
weight: '',
|
||||
quantity: '',
|
||||
cost: '',
|
||||
price: ''
|
||||
}
|
||||
],
|
||||
/** 要提交的规格数据*/
|
||||
skuInfo: [],
|
||||
|
||||
/** 当前规格项下的规格值列表*/
|
||||
specList: [],
|
||||
|
||||
/** 当前规格项索引 */
|
||||
activeSkuItemIndex: 0,
|
||||
|
||||
/** 当前规格项 */
|
||||
activeSkuItem: {},
|
||||
|
||||
/** 规格图片 */
|
||||
images: [],
|
||||
/** 当前规格值索引 */
|
||||
activeSkuValIndex: 0,
|
||||
|
||||
/** 当前规格值 */
|
||||
activeSkuVal: {},
|
||||
/** 存储未通过校验的单元格位置 */
|
||||
validateError: [],
|
||||
//规格照片
|
||||
checkedImage:false
|
||||
};
|
||||
},
|
||||
mounted(){
|
||||
|
||||
},
|
||||
watch: {
|
||||
/** 自动生成货号 */
|
||||
productSn() {
|
||||
if (this.productSn && this.skuTableData.length > 0) {
|
||||
let count = 1
|
||||
this.skuTableData.forEach(key => {
|
||||
key.sn = this.goodsSn + '-00000' + count
|
||||
count++
|
||||
})
|
||||
/** 异步更新skuTableData数据 */
|
||||
this.$emit("getTableData", this.skuTableData);
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
uploadchange(url){
|
||||
/**
|
||||
* 渲染规格详细表格
|
||||
*/
|
||||
this.renderTableData();
|
||||
},
|
||||
/** 添加规格项 */
|
||||
addSkuItem() {
|
||||
// 写入对象,下标,具体对象
|
||||
this.$set(this.skuInfo, this.skuInfo.length, {
|
||||
spec_values: []
|
||||
});
|
||||
/**
|
||||
* 渲染规格详细表格
|
||||
*/
|
||||
this.renderTableData();
|
||||
},
|
||||
|
||||
/** 移除当前规格项 进行数据变化*/
|
||||
handleCloseSkuItem($index) {
|
||||
this.skuInfo.splice($index, 1);
|
||||
/**
|
||||
* 渲染规格详细表格
|
||||
*/
|
||||
this.renderTableData();
|
||||
},
|
||||
|
||||
/** 规格变更 */
|
||||
skuItemChange(value, $index) {
|
||||
this.activeSkuItemIndex = $index;
|
||||
//判定是否存在这个规格分组
|
||||
let item = this.findSpec(value);
|
||||
/** 更新skuInfo数据 */
|
||||
this.$set(this.skuInfo[this.activeSkuItemIndex], "name", item.name);
|
||||
this.$set(this.skuInfo[this.activeSkuItemIndex], "spec_values", []);
|
||||
/**
|
||||
* 渲染规格详细表格
|
||||
*/
|
||||
this.renderTableData();
|
||||
},
|
||||
/**
|
||||
* 根据规格项名称,搜索对应的规格对象(如果是服务器设置过的话)
|
||||
*/
|
||||
findSpec(name) {
|
||||
let spec = { name: name };
|
||||
this.skuData.forEach(item => {
|
||||
if (item.name === name) {
|
||||
spec = item;
|
||||
}
|
||||
});
|
||||
return spec;
|
||||
},
|
||||
|
||||
/** 选中/不选中 添加规格图片 是否显示上传组件*/
|
||||
handleChangeImage(val) {
|
||||
this.$set(this.skuInfo, this.skuInfo.length, {});
|
||||
this.skuInfo.splice(this.skuInfo.length - 1, 1);
|
||||
this.checkedImage = val;
|
||||
/** 如果 图片按钮不显示 则置空图片列表中的所有图片数据 并且spec_type设置为0 */
|
||||
if (!val) {
|
||||
this.skuInfo.forEach(key => {
|
||||
if (key.spec_values) {
|
||||
key.spec_values.forEach(item => {
|
||||
item.spec_image = "";
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 渲染规格详细表格
|
||||
*/
|
||||
this.renderTableData();
|
||||
|
||||
|
||||
},
|
||||
|
||||
/** 规格值 */
|
||||
|
||||
/** 添加当前规格项的规格值*/
|
||||
addSpec($index, item) {
|
||||
this.activeSkuItemIndex = $index;
|
||||
this.$set(
|
||||
this.skuInfo[$index].spec_values,
|
||||
this.skuInfo[$index].spec_values.length,
|
||||
{
|
||||
name: item.name
|
||||
}
|
||||
);
|
||||
/**
|
||||
* 渲染规格详细表格
|
||||
*/
|
||||
this.renderTableData();
|
||||
},
|
||||
|
||||
/** 移除当前规格值 */
|
||||
handleCloseSkuValue($index, index) {
|
||||
this.skuInfo[$index].spec_values.splice(index, 1);
|
||||
/**
|
||||
* 渲染规格详细表格
|
||||
*/
|
||||
this.renderTableData();
|
||||
},
|
||||
|
||||
/** 选择规格值时触发 */
|
||||
skuValueChange(val) {
|
||||
/** 更新skuInfo数据 */
|
||||
let _arr = cloneObj(this.skuInfo[this.activeSkuItemIndex]);
|
||||
this.$set(_arr.spec_values[this.activeSkuValIndex], "name", _arr.name);
|
||||
this.$set(this.skuInfo, this.activeSkuItemIndex, _arr);
|
||||
/**
|
||||
* 渲染规格详细表格
|
||||
*/
|
||||
this.renderTableData();
|
||||
},
|
||||
|
||||
/** 编辑规格值时触发 */
|
||||
editSkuIValue($index) {
|
||||
if (this.skuInfo.length >= $index) {
|
||||
let data = this.findSpec(this.skuInfo[$index].name);
|
||||
this.skuValue = data.value;
|
||||
}
|
||||
/**
|
||||
* 渲染规格详细表格
|
||||
*/
|
||||
this.renderTableData();
|
||||
},
|
||||
/** 获取编辑时的skuInfo信息 */
|
||||
getSkuInfo() {
|
||||
/** 下拉列表数据(skuData)存在时 检测productSkuInfo中对应的规格(spec_id)项 并且赋值于skuInfo中对应的规格项信息(描述 + 名称) */
|
||||
if (this.categoryId) {
|
||||
API_spec.getSpecValuesListData(this.categoryId, {}).then(response => {
|
||||
this.skuData = response;
|
||||
if (
|
||||
this.skuData.length > 0 &&
|
||||
Array.isArray(this.productSkuInfo) &&
|
||||
this.productSkuInfo.length > 0
|
||||
) {
|
||||
this.skuInfo = cloneObj(this.productSkuInfo);
|
||||
if (this.skuInfo.length > 0) {
|
||||
this.skuInfo.forEach(key => {
|
||||
this.skuData.forEach(item => {
|
||||
if (key.spec_id === item.spec_id) {
|
||||
key.name = item.name;
|
||||
key.spec_memo = item.spec_memo;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/** 如果存在图片则进行显示 */
|
||||
if (this.skuInfo[0].spec_values[0].spec_type === 1) {
|
||||
this.checkedImage = true;
|
||||
}
|
||||
/** 触发一次数据转换(规格选择数据=> 规格表格数据) */
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 渲染规格详细表格
|
||||
*/
|
||||
this.renderTableData();
|
||||
},
|
||||
/**
|
||||
* 渲染table所需要的column 和 data
|
||||
*/
|
||||
renderTableData() {
|
||||
this.skuTableColumn = [];
|
||||
this.skuTableData = [];
|
||||
|
||||
//渲染头部
|
||||
|
||||
this.skuInfo.forEach(sku => {
|
||||
//列名称
|
||||
let columnName = sku.name;
|
||||
this.skuTableColumn.push({
|
||||
title: columnName,
|
||||
key: columnName
|
||||
});
|
||||
});
|
||||
this.skuTableColumn.push(
|
||||
{
|
||||
title: "货号",
|
||||
slot: "sn"
|
||||
},
|
||||
{
|
||||
title: "重量",
|
||||
slot: "weight"
|
||||
},
|
||||
{
|
||||
title: "库存",
|
||||
slot: "quantity"
|
||||
},
|
||||
{
|
||||
title: "成本价",
|
||||
slot: "cost"
|
||||
},
|
||||
{
|
||||
title: "价格",
|
||||
slot: "price"
|
||||
}
|
||||
);
|
||||
|
||||
//克隆所有渲染的数据
|
||||
let cloneTemp = cloneObj(this.skuInfo);
|
||||
|
||||
//数据清空一次
|
||||
this.skuTableData = [];
|
||||
//判定 是否存在规格分组
|
||||
if (cloneTemp[0]) {
|
||||
//存放最终结果
|
||||
let result = [];
|
||||
|
||||
//记录存放表格的 key
|
||||
//循环选中的 sku 数据
|
||||
if(this.checkedImage===false){
|
||||
cloneTemp[0].spec_values.forEach(specItem => {
|
||||
result.push({
|
||||
[specItem.name]: specItem.value
|
||||
});
|
||||
});
|
||||
}else{
|
||||
cloneTemp[0].spec_values.forEach(specItem => {
|
||||
result.push({
|
||||
[specItem.name]: specItem.value,
|
||||
images: specItem.spec_image
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
cloneTemp.splice(0, 1);
|
||||
|
||||
result = this.specIterator(result, cloneTemp);
|
||||
result = this.defaultParams(result);
|
||||
this.skuTableData = result;
|
||||
}
|
||||
this.$emit("getTableData", this.skuTableData);
|
||||
},
|
||||
|
||||
/** 自动完成表单所需方法*/
|
||||
filterMethod(value, option) {
|
||||
return option.toUpperCase().indexOf(value.toUpperCase()) !== -1;
|
||||
},
|
||||
|
||||
/** 根据分类id获取系统设置规格信息*/
|
||||
Get_SkuInfoByCategory() {
|
||||
if (this.baseInfoForm.categoryId) {
|
||||
getGoodsSpecInfo(this.baseInfoForm.categoryId, {}).then(response => {
|
||||
this.skuData = response;
|
||||
if (this.skuData.length > 0) {
|
||||
this.skuData.forEach(spec => {
|
||||
this.skuKey.push(spec.name);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
/** 检测是否未通过0-99999999之间的数字校验 */
|
||||
isValidate(index, scope) {
|
||||
return this.validateError.some(key => {
|
||||
return key[0] === index && key[1] === scope.$index
|
||||
})
|
||||
},
|
||||
/** 数据改变之后 抛出数据 */
|
||||
updateSkuTable(row, item) {
|
||||
let index = row._index;
|
||||
this.skuTableData[index][item] = row[item];
|
||||
/** 进行自定义校验 判断是否是数字(小数也能通过)重量 */
|
||||
if (
|
||||
(!/^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/.test(row[item]) &&
|
||||
item === "weight") ||
|
||||
parseInt(row[item]) < 0 ||
|
||||
parseInt(row[item]) > 99999999
|
||||
) {
|
||||
this.$Message.error("请输入0~99999999之间的数字值");
|
||||
return;
|
||||
} else if (
|
||||
(item === "quantity" && !/^[0-9]\d*$/.test(row[item])) ||
|
||||
parseInt(row[item]) < 0 ||
|
||||
parseInt(row[item]) > 99999999
|
||||
) {
|
||||
// 库存
|
||||
this.$Message.error("请输入0~99999999之间的整数");
|
||||
return;
|
||||
} else if (
|
||||
((item === "cost" || item === "price") &&
|
||||
!regular.money.test(row[item])) ||
|
||||
parseInt(row[item]) < 0 ||
|
||||
parseInt(row[item]) > 99999999
|
||||
) {
|
||||
// 成本价 价格
|
||||
this.$Message.error("请输入0~99999999之间的价格");
|
||||
return;
|
||||
}
|
||||
this.skuTableData[index][item] = row[item];
|
||||
this.$emit("getTableData", this.skuTableData);
|
||||
// console.log(999, this.skuTableData)
|
||||
},
|
||||
/**
|
||||
* 迭代属性,形成表格
|
||||
* result 渲染的数据
|
||||
* array spec数据
|
||||
*/
|
||||
specIterator(result, cloneTemp) {
|
||||
//是否还可以循环
|
||||
if (cloneTemp.length > 0) {
|
||||
let table = [];
|
||||
result.forEach(resItem => {
|
||||
let tableItem = [];
|
||||
cloneTemp[0].spec_values.forEach(valItem => {
|
||||
let obj = cloneObj(resItem);
|
||||
obj[valItem.name] = valItem.value;
|
||||
table.push(obj);
|
||||
});
|
||||
});
|
||||
result = [];
|
||||
table.forEach(t => {
|
||||
result.push(t);
|
||||
});
|
||||
//清除当前循环的分组
|
||||
cloneTemp.splice(0, 1);
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
return this.specIterator(result, cloneTemp);
|
||||
},
|
||||
showData() {
|
||||
// console.log(JSON.stringify(this.skuTableData));
|
||||
// console.warn(this.specList);
|
||||
},
|
||||
/**
|
||||
* 添加固有属性
|
||||
*/
|
||||
defaultParams(tableData) {
|
||||
return tableData;
|
||||
},
|
||||
|
||||
handleSpan({ row, column, rowIndex, columnIndex }) {},
|
||||
|
||||
thumbChange(){
|
||||
this.$emit("getTableData", this.skuTableData);
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.layout {
|
||||
margin-bottom: 20px;
|
||||
|
||||
.sku-item-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
|
||||
.sku-item-content-name {
|
||||
margin-top: 24px;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.demo-upload-list{
|
||||
display: inline-block;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
text-align: center;
|
||||
line-height: 60px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
position: relative;
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,.2);
|
||||
margin-right: 4px;
|
||||
}
|
||||
.demo-upload-list img{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.demo-upload-list-cover{
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: rgba(0,0,0,.6);
|
||||
}
|
||||
.demo-upload-list:hover .demo-upload-list-cover{
|
||||
display: block;
|
||||
}
|
||||
.demo-upload-list-cover i{
|
||||
color: #fff;
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
margin: 0 2px;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
@@ -1,114 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<Button
|
||||
:countTime="countTime"
|
||||
:loading="loading"
|
||||
:type="type"
|
||||
:size="size"
|
||||
:ghost="ghost"
|
||||
:disabled="disabled||clicked"
|
||||
:icon="icon"
|
||||
:shape="shape"
|
||||
:long="long"
|
||||
@click="handleClick"
|
||||
>{{buttonText}}</Button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "iconChoose",
|
||||
props: {
|
||||
text: {
|
||||
type: String,
|
||||
default: "提交"
|
||||
},
|
||||
autoCountDown: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
countTime: {
|
||||
type: [Number, String],
|
||||
default: 60
|
||||
},
|
||||
suffixText: {
|
||||
type: String,
|
||||
default: "后重试"
|
||||
},
|
||||
type: String,
|
||||
size: String,
|
||||
loading: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
ghost: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
icon: String,
|
||||
shape: String,
|
||||
long: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
buttonText: this.text, // 按钮文字
|
||||
count: Number(this.countTime), // 计时时间
|
||||
clicked: false // 是否可点击
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
init() {},
|
||||
handleClick() {
|
||||
if (this.autoCountDown) {
|
||||
this.clicked = true;
|
||||
this.countDown();
|
||||
}
|
||||
this.$emit("on-click", true);
|
||||
},
|
||||
startCountDown() {
|
||||
this.clicked = true;
|
||||
this.countDown();
|
||||
},
|
||||
countDown() {
|
||||
let that = this;
|
||||
if (this.count == 0) {
|
||||
this.clicked = false;
|
||||
this.count = this.countTime;
|
||||
this.buttonText = this.text;
|
||||
return;
|
||||
} else {
|
||||
this.buttonText = this.count + " 秒" + this.suffixText;
|
||||
this.count--;
|
||||
}
|
||||
setTimeout(function() {
|
||||
that.countDown();
|
||||
}, 1000);
|
||||
},
|
||||
setText(value) {
|
||||
if (value === this.buttonText) {
|
||||
return;
|
||||
}
|
||||
this.buttonText = value;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
text(val) {
|
||||
this.setText(val);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
</style>
|
||||
|
||||
@@ -1,346 +0,0 @@
|
||||
<template>
|
||||
<div class="sku-choose">
|
||||
<Button @click="showDrawer=true" :icon="icon">{{ text }}</Button>
|
||||
<span @click="clearSelectData" class="clear">清空已选</span>
|
||||
<Collapse simple class="collapse">
|
||||
<Panel name="1">
|
||||
已选择
|
||||
<span class="select-count">{{ selectObj.length }}</span> 件
|
||||
<p slot="content">
|
||||
<Tag
|
||||
v-for="(item, i) in selectObj"
|
||||
:key="i"
|
||||
:name="item.id"
|
||||
color="default"
|
||||
closable
|
||||
@on-close="handleCancelObj"
|
||||
>{{ createName(item) }}
|
||||
</Tag>
|
||||
</p>
|
||||
</Panel>
|
||||
</Collapse>
|
||||
<Drawer title="选择活动优惠券" closable v-model="showDrawer" :width="width" draggable>
|
||||
<Table
|
||||
:loading="showLoading"
|
||||
border
|
||||
:columns="tableColumns"
|
||||
:data="tableData"
|
||||
:height="height"
|
||||
ref="tableData"
|
||||
></Table>
|
||||
<Row type="flex" justify="end" style="margin: 10px 0;">
|
||||
<Page
|
||||
:current="searchForm.pageNumber"
|
||||
:total="tableTotal"
|
||||
:page-size="searchForm.pageSize"
|
||||
@on-change="changeDataPage"
|
||||
@on-page-size-change="changeDataPageSize"
|
||||
:page-size-opts="[10,20,50]"
|
||||
size="small"
|
||||
show-total
|
||||
show-elevator
|
||||
show-sizer
|
||||
></Page>
|
||||
</Row>
|
||||
<div class="my-drawer-footer">
|
||||
已选择
|
||||
<span class="select-count">{{ selectObj.length }}</span> 件
|
||||
<Button @click="clearSelectData" style="margin-left:10px">清空已选</Button>
|
||||
<Button @click="showDrawer=false" type="primary" style="margin-left:10px">关闭</Button>
|
||||
</div>
|
||||
</Drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getPlatformCouponList
|
||||
} from "@/api/promotion";
|
||||
|
||||
export default {
|
||||
name: "userChoose",
|
||||
props: {
|
||||
text: {
|
||||
type: String,
|
||||
default: "选择SKU"
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
default: "md-basket"
|
||||
},
|
||||
initData: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
createName: {
|
||||
type: Function,
|
||||
default: function (item) {
|
||||
return item.goodsName
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.selectObj = this.initData
|
||||
console.log(JSON.stringify(this.initData))
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
//默认值后续计算
|
||||
height: 500,
|
||||
width: 500,
|
||||
//加载状态
|
||||
showLoading: true,
|
||||
//展示抽屉
|
||||
showDrawer: false,
|
||||
selectObj: [], // 选择数据
|
||||
searchForm: { // 请求参数
|
||||
getType: "ACTIVITY",// 活动优惠券
|
||||
pageNumber: 1, // 当前页数
|
||||
pageSize: 10, // 页面大小
|
||||
sort: "createTime", // 默认排序字段
|
||||
order: "desc", // 默认排序方式
|
||||
|
||||
},
|
||||
tableColumns: [ // 表头
|
||||
{
|
||||
type: "index",
|
||||
width: 60,
|
||||
align: "center"
|
||||
},
|
||||
{
|
||||
title: "商品名称",
|
||||
key: "goodsName",
|
||||
minWidth: 140
|
||||
},
|
||||
{
|
||||
title: "规格",
|
||||
key: "specName",
|
||||
minWidth: 140,
|
||||
},
|
||||
{
|
||||
title: "图片",
|
||||
key: "thumbnail",
|
||||
width: 80,
|
||||
align: "center",
|
||||
render: (h, params) => {
|
||||
return h("Avatar", {
|
||||
props: {
|
||||
src: params.row.face
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
key: "status",
|
||||
align: "center",
|
||||
width: 120,
|
||||
render: (h, params) => {
|
||||
if (params.row.delFlag == 0) {
|
||||
return h("div", [
|
||||
h("Badge", {
|
||||
props: {
|
||||
status: "success",
|
||||
text: "正常"
|
||||
}
|
||||
})
|
||||
]);
|
||||
} else if (params.row.delFlag == -1) {
|
||||
return h("div", [
|
||||
h("Badge", {
|
||||
props: {
|
||||
status: "error",
|
||||
text: "禁用"
|
||||
}
|
||||
})
|
||||
]);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "创建时间",
|
||||
key: "createTime",
|
||||
sortable: true,
|
||||
sortType: "desc",
|
||||
width: 170
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
key: "action",
|
||||
width: 130,
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
render: (h, params) => {
|
||||
let select;
|
||||
this.selectObj.forEach(item => {
|
||||
if (item.id === params.row.id) {
|
||||
select = params.row
|
||||
}
|
||||
});
|
||||
|
||||
if (select) {
|
||||
return h("div", [
|
||||
h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "info",
|
||||
size: "small"
|
||||
},
|
||||
on: {
|
||||
click: () => {
|
||||
this.chooseCancel(params.row);
|
||||
}
|
||||
}
|
||||
},
|
||||
"取消选择"
|
||||
)
|
||||
]);
|
||||
} else {
|
||||
return h("div", [
|
||||
h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "info",
|
||||
size: "small"
|
||||
},
|
||||
on: {
|
||||
click: () => {
|
||||
this.chooseObj(params.row);
|
||||
}
|
||||
}
|
||||
},
|
||||
"选择"
|
||||
)
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
tableData: [], // 表格数据
|
||||
tableTotal: 0 // 总数
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
changeDataPage(v) {
|
||||
this.searchForm.pageNumber = v;
|
||||
this.searchData();
|
||||
},
|
||||
changeDataPageSize(v) {
|
||||
this.searchForm.pageSize = v;
|
||||
this.searchData();
|
||||
},
|
||||
searchData() {
|
||||
this.showLoading = true;
|
||||
getPlatformCouponList(this.searchForm).then(res => {
|
||||
this.showLoading = false;
|
||||
if (res.success) {
|
||||
this.tableData = res.result.records;
|
||||
this.tableTotal = res.result.total;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
handleSearchData() {
|
||||
this.searchForm.pageNumber = 1;
|
||||
this.searchForm.pageSize = 10;
|
||||
this.searchData();
|
||||
},
|
||||
handleResetObj() {
|
||||
this.$refs.searchForm.resetFields();
|
||||
this.searchForm.pageNumber = 1;
|
||||
this.searchForm.pageSize = 9;
|
||||
this.searchForm.departmentId = "";
|
||||
// 重新加载数据
|
||||
this.searchData();
|
||||
},
|
||||
setData(v) {
|
||||
this.selectObj = v;
|
||||
this.$emit("on-change", this.selectObj);
|
||||
},
|
||||
chooseCancel(v) {
|
||||
let _index;
|
||||
this.selectObj.forEach((e, index) => {
|
||||
if (v.id == e.id) {
|
||||
_index = index;
|
||||
}
|
||||
});
|
||||
|
||||
if (_index || _index == 0) {
|
||||
this.selectObj.splice(_index, 1);
|
||||
this.$emit("on-change", this.selectObj);
|
||||
}
|
||||
},
|
||||
chooseObj(v) {
|
||||
// 去重
|
||||
let that = this;
|
||||
let flag = true;
|
||||
this.selectObj.forEach(e => {
|
||||
if (v.id == e.id) {
|
||||
flag = false;
|
||||
}
|
||||
});
|
||||
if (flag) {
|
||||
this.selectObj.push(v);
|
||||
this.$emit("on-change", this.selectObj);
|
||||
}
|
||||
},
|
||||
clearSelectData() {
|
||||
this.selectObj = [];
|
||||
this.$emit("on-change", this.selectObj);
|
||||
},
|
||||
handleCancelObj(e, id) {
|
||||
// 删除所选用户
|
||||
let newArray = [];
|
||||
this.selectObj.forEach(e => {
|
||||
if (id != e.id) {
|
||||
newArray.push(e);
|
||||
}
|
||||
});
|
||||
this.selectObj = newArray;
|
||||
this.$emit("on-change", this.selectObj);
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// 计算高度
|
||||
this.height = Number(document.documentElement.clientHeight - 230);
|
||||
this.width = Number(document.documentElement.clientWidth / 2) > 900 ? 900 : Number(document.documentElement.clientWidth / 2)
|
||||
this.searchData();
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.sku-choose {
|
||||
.clear {
|
||||
font-size: 12px;
|
||||
margin-left: 15px;
|
||||
color: #40a9ff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.collapse {
|
||||
font-size: 12px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.select-count {
|
||||
font-weight: 600;
|
||||
color: #40a9ff;
|
||||
}
|
||||
}
|
||||
|
||||
.my-drawer-footer {
|
||||
z-index: 10;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
border-top: 1px solid #e8e8e8;
|
||||
padding: 10px 16px;
|
||||
text-align: right;
|
||||
background: #fff;
|
||||
}
|
||||
</style>
|
||||
@@ -14,7 +14,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { initDepartment, loadDepartment } from "@/api/index";
|
||||
import { initDepartment } from "@/api/index";
|
||||
export default {
|
||||
name: "departmentChoose",
|
||||
props: {
|
||||
@@ -27,50 +27,13 @@ export default {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
// 获取部门数据
|
||||
initDepartmentData() {
|
||||
initDepartment().then(res => {
|
||||
if (res.success) {
|
||||
res.result.forEach(function(e) {
|
||||
if (e.isParent) {
|
||||
e.value = e.id;
|
||||
e.label = e.title;
|
||||
e.loading = false;
|
||||
e.children = [];
|
||||
} else {
|
||||
e.value = e.id;
|
||||
e.label = e.title;
|
||||
}
|
||||
if (e.status == -1) {
|
||||
e.label = "[已禁用] " + e.label;
|
||||
e.disabled = true;
|
||||
}
|
||||
});
|
||||
this.department = res.result;
|
||||
}
|
||||
});
|
||||
},
|
||||
loadData(item, callback) {
|
||||
item.loading = true;
|
||||
loadDepartment(item.value).then(res => {
|
||||
item.loading = false;
|
||||
if (res.success) {
|
||||
res.result.forEach(function(e) {
|
||||
if (e.isParent) {
|
||||
e.value = e.id;
|
||||
e.label = e.title;
|
||||
e.loading = false;
|
||||
e.children = [];
|
||||
} else {
|
||||
e.value = e.id;
|
||||
e.label = e.title;
|
||||
}
|
||||
if (e.status == -1) {
|
||||
e.label = "[已禁用] " + e.label;
|
||||
e.disabled = true;
|
||||
}
|
||||
});
|
||||
item.children = res.result;
|
||||
callback();
|
||||
const arr = res.result;
|
||||
this.filterData(arr)
|
||||
this.department = arr
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -82,8 +45,21 @@ export default {
|
||||
}
|
||||
this.$emit("on-change", departmentId);
|
||||
},
|
||||
// 清空已选列表
|
||||
clearSelect() {
|
||||
this.selectDep = [];
|
||||
},
|
||||
// 处理部门数据
|
||||
filterData (data) {
|
||||
data.forEach(e => {
|
||||
e.value = e.id;
|
||||
e.label = e.title;
|
||||
if (e.children) {
|
||||
this.filterData(e.children)
|
||||
} else {
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
<div class="dep-tree-bar">
|
||||
<Tree
|
||||
:data="dataDep"
|
||||
:load-data="loadData"
|
||||
@on-select-change="selectTree"
|
||||
></Tree>
|
||||
<Spin size="large" fix v-if="depLoading"></Spin>
|
||||
@@ -34,7 +33,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {initDepartment, loadDepartment, searchDepartment} from "@/api/index";
|
||||
import {initDepartment, searchDepartment} from "@/api/index";
|
||||
|
||||
export default {
|
||||
name: "departmentTreeChoose",
|
||||
@@ -63,40 +62,14 @@ export default {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
// 获取部门数据
|
||||
initDepartmentData() {
|
||||
initDepartment().then(res => {
|
||||
if (res.success) {
|
||||
res.result.forEach(function (e) {
|
||||
if (e.isParent) {
|
||||
e.loading = false;
|
||||
e.children = [];
|
||||
}
|
||||
if (e.status == -1) {
|
||||
e.title = "[已禁用] " + e.title;
|
||||
e.disabled = true;
|
||||
}
|
||||
});
|
||||
this.dataDep = res.result;
|
||||
}
|
||||
});
|
||||
},
|
||||
loadData(item, callback) {
|
||||
loadDepartment(item.id).then(res => {
|
||||
if (res.success) {
|
||||
res.result.forEach(function (e) {
|
||||
if (e.isParent) {
|
||||
e.loading = false;
|
||||
e.children = [];
|
||||
}
|
||||
if (e.status == -1) {
|
||||
e.title = "[已禁用] " + e.title;
|
||||
e.disabled = true;
|
||||
}
|
||||
});
|
||||
callback(res.result);
|
||||
}
|
||||
});
|
||||
},
|
||||
searchDep() {
|
||||
// 搜索部门
|
||||
if (this.searchKey) {
|
||||
@@ -117,6 +90,7 @@ export default {
|
||||
this.initDepartmentData();
|
||||
}
|
||||
},
|
||||
// 选择回调
|
||||
selectTree(v) {
|
||||
if (v.length === 0) {
|
||||
this.$emit("on-change", null);
|
||||
@@ -132,6 +106,7 @@ export default {
|
||||
}
|
||||
this.$emit("on-change", department);
|
||||
},
|
||||
// 清除选中方法
|
||||
clearSelect() {
|
||||
this.departmentId = [];
|
||||
this.departmentTitle = "";
|
||||
@@ -143,6 +118,7 @@ export default {
|
||||
}
|
||||
this.$emit("on-clear");
|
||||
},
|
||||
// 设置数据 回显用
|
||||
setData(ids, title) {
|
||||
this.departmentTitle = title;
|
||||
if (this.multiple) {
|
||||
@@ -151,7 +127,6 @@ export default {
|
||||
this.departmentId = [];
|
||||
this.departmentId.push(ids);
|
||||
}
|
||||
// this.$emit("on-change", this.departmentId);
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
@@ -159,16 +159,19 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
// 编辑html
|
||||
editHTML() {
|
||||
this.dataEdit = this.data;
|
||||
this.showHTMLModal = true;
|
||||
},
|
||||
// 保存
|
||||
editHTMLOk() {
|
||||
editor.txt.html(this.dataEdit);
|
||||
this.$emit("input", this.data);
|
||||
this.$emit("on-change", this.data);
|
||||
this.showHTMLModal = false;
|
||||
},
|
||||
// 清空编辑器
|
||||
clear() {
|
||||
this.$Modal.confirm({
|
||||
title: "确认清空",
|
||||
@@ -181,6 +184,7 @@ export default {
|
||||
},
|
||||
});
|
||||
},
|
||||
// 回显数据
|
||||
setData(value) {
|
||||
if (!editor) {
|
||||
this.initEditor();
|
||||
|
||||
@@ -1,346 +0,0 @@
|
||||
<template>
|
||||
<div class="member-choose">
|
||||
<Button @click="userModalVisible=true" :icon="icon">{{text}}</Button>
|
||||
<span @click="clearSelectData" class="clear">清空已选</span>
|
||||
<Collapse simple class="collapse">
|
||||
<Panel name="1">
|
||||
已选择
|
||||
<span class="select-count">{{selectUsers.length}}</span> 人
|
||||
<p slot="content">
|
||||
<Tag
|
||||
v-for="(item, i) in selectUsers"
|
||||
:key="i"
|
||||
:name="item.id"
|
||||
color="default"
|
||||
closable
|
||||
@on-close="handleCancelUser"
|
||||
>{{item.username}}
|
||||
</Tag>
|
||||
</p>
|
||||
</Panel>
|
||||
</Collapse>
|
||||
<Drawer title="选择用户" closable v-model="userModalVisible" width="800" draggable>
|
||||
<Form ref="searchUserForm" :model="searchUserForm" inline :label-width="55">
|
||||
<Form-item label="用户名" prop="username">
|
||||
<Input
|
||||
type="text"
|
||||
v-model="searchUserForm.username"
|
||||
clearable
|
||||
placeholder="请输入用户名"
|
||||
style="width: 200px"
|
||||
/>
|
||||
</Form-item>
|
||||
<Form-item style="margin-left:-35px;" class="br">
|
||||
<Button @click="handleSearchUser" type="primary" icon="ios-search">搜索</Button>
|
||||
<Button @click="handleResetUser">重置</Button>
|
||||
</Form-item>
|
||||
</Form>
|
||||
<Table
|
||||
:loading="userLoading"
|
||||
border
|
||||
:columns="userColumns"
|
||||
:data="userData"
|
||||
:height="height"
|
||||
ref="userTable"
|
||||
></Table>
|
||||
<Row type="flex" justify="end" style="margin: 10px 0;">
|
||||
<Page
|
||||
:current="searchUserForm.pageNumber"
|
||||
:total="totalUser"
|
||||
:page-size="searchUserForm.pageSize"
|
||||
@on-change="changeUserPage"
|
||||
@on-page-size-change="changeUserPageSize"
|
||||
:page-size-opts="[10,20,50]"
|
||||
size="small"
|
||||
show-total
|
||||
show-elevator
|
||||
show-sizer
|
||||
></Page>
|
||||
</Row>
|
||||
<div class="my-drawer-footer">
|
||||
已选择
|
||||
<span class="select-count">{{selectUsers.length}}</span> 人
|
||||
<Button @click="clearSelectData" style="margin-left:10px">清空已选</Button>
|
||||
<Button @click="userModalVisible=false" type="primary" style="margin-left:10px">关闭</Button>
|
||||
</div>
|
||||
</Drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {getMember} from "@/api/member";
|
||||
|
||||
export default {
|
||||
name: "userChoose",
|
||||
props: {
|
||||
text: {
|
||||
type: String,
|
||||
default: "选择会员"
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
default: "md-person-add"
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
height: 500, // 表格高度
|
||||
userLoading: true, // 加载状态
|
||||
userModalVisible: false, // modal显隐
|
||||
selectUsers: [], // 已选用户
|
||||
searchUserForm: { // 请求参数
|
||||
username: "",
|
||||
pageNumber: 1, // 当前页数
|
||||
pageSize: 10, // 页面大小
|
||||
sort: "createTime", // 默认排序字段
|
||||
order: "desc" // 默认排序方式
|
||||
},
|
||||
userColumns: [ // 表头
|
||||
{
|
||||
type: "index",
|
||||
width: 60,
|
||||
align: "center"
|
||||
},
|
||||
{
|
||||
title: "用户名",
|
||||
key: "username",
|
||||
minWidth: 140,
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
title: "头像",
|
||||
key: "face",
|
||||
width: 80,
|
||||
align: "center",
|
||||
render: (h, params) => {
|
||||
return h("Avatar", {
|
||||
props: {
|
||||
src: params.row.face
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "手机",
|
||||
key: "mobile",
|
||||
width: 125,
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
key: "status",
|
||||
align: "center",
|
||||
width: 120,
|
||||
render: (h, params) => {
|
||||
if (params.row.delFlag == 0) {
|
||||
return h("div", [
|
||||
h("Badge", {
|
||||
props: {
|
||||
status: "success",
|
||||
text: "正常启用"
|
||||
}
|
||||
})
|
||||
]);
|
||||
} else if (params.row.delFlag == -1) {
|
||||
return h("div", [
|
||||
h("Badge", {
|
||||
props: {
|
||||
status: "error",
|
||||
text: "禁用"
|
||||
}
|
||||
})
|
||||
]);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "创建时间",
|
||||
key: "createTime",
|
||||
sortable: true,
|
||||
sortType: "desc",
|
||||
width: 170
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
key: "action",
|
||||
width: 130,
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
render: (h, params) => {
|
||||
let select;
|
||||
this.selectUsers.forEach(item => {
|
||||
if (item.id === params.row.id) {
|
||||
select = params.row
|
||||
}
|
||||
});
|
||||
|
||||
if (select) {
|
||||
return h("div", [
|
||||
h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "info",
|
||||
size: "small"
|
||||
},
|
||||
on: {
|
||||
click: () => {
|
||||
this.chooseCancel(params.row);
|
||||
}
|
||||
}
|
||||
},
|
||||
"取消选择"
|
||||
)
|
||||
]);
|
||||
} else {
|
||||
return h("div", [
|
||||
h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "info",
|
||||
size: "small"
|
||||
},
|
||||
on: {
|
||||
click: () => {
|
||||
this.chooseUser(params.row);
|
||||
}
|
||||
}
|
||||
},
|
||||
"选择"
|
||||
)
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
userData: [], // 用户数据
|
||||
totalUser: 0 // 数量
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
changeUserPage(v) {
|
||||
this.searchUserForm.pageNumber = v;
|
||||
this.getUserDataList();
|
||||
},
|
||||
changeUserPageSize(v) {
|
||||
this.searchUserForm.pageSize = v;
|
||||
this.getUserDataList();
|
||||
},
|
||||
getUserDataList() {
|
||||
this.userLoading = true;
|
||||
getMember(this.searchUserForm).then(res => {
|
||||
this.userLoading = false;
|
||||
if (res.success) {
|
||||
this.userData = res.result.records;
|
||||
this.totalUser = res.result.total;
|
||||
}
|
||||
});
|
||||
},
|
||||
handleSearchUser() {
|
||||
this.searchUserForm.pageNumber = 1;
|
||||
this.searchUserForm.pageSize = 10;
|
||||
this.getUserDataList();
|
||||
},
|
||||
handleResetUser() {
|
||||
this.$refs.searchUserForm.resetFields();
|
||||
this.searchUserForm.pageNumber = 1;
|
||||
this.searchUserForm.pageSize = 9;
|
||||
this.$refs.dep.clearSelect();
|
||||
this.searchUserForm.departmentId = "";
|
||||
// 重新加载数据
|
||||
this.getUserDataList();
|
||||
},
|
||||
setData(v) {
|
||||
this.selectUsers = v;
|
||||
this.$emit("on-change", this.selectUsers);
|
||||
},
|
||||
chooseCancel(v){
|
||||
let _index;
|
||||
this.selectUsers.forEach((e,index) => {
|
||||
if (v.id == e.id) {
|
||||
_index = index;
|
||||
}
|
||||
});
|
||||
|
||||
if(_index||_index==0){
|
||||
this.selectUsers.splice(_index,1);
|
||||
this.$emit("on-change", this.selectUsers);
|
||||
}
|
||||
},
|
||||
chooseUser(v) {
|
||||
// 去重
|
||||
let that = this;
|
||||
let flag = true;
|
||||
this.selectUsers.forEach(e => {
|
||||
if (v.id == e.id) {
|
||||
flag = false;
|
||||
}
|
||||
});
|
||||
if (flag) {
|
||||
let u = {
|
||||
id: v.id,
|
||||
username: v.username
|
||||
};
|
||||
this.selectUsers.push(u);
|
||||
this.$emit("on-change", this.selectUsers);
|
||||
}
|
||||
},
|
||||
clearSelectData() {
|
||||
this.selectUsers = [];
|
||||
this.$emit("on-change", this.selectUsers);
|
||||
},
|
||||
handleCancelUser(e, id) {
|
||||
// 删除所选用户
|
||||
let newArray = [];
|
||||
this.selectUsers.forEach(e => {
|
||||
if (id != e.id) {
|
||||
newArray.push(e);
|
||||
}
|
||||
});
|
||||
this.selectUsers = newArray;
|
||||
this.$emit("on-change", this.selectUsers);
|
||||
this.$Message.success("删除所选用户成功");
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// 计算高度
|
||||
this.height = Number(document.documentElement.clientHeight - 230);
|
||||
this.getUserDataList();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.member-choose {
|
||||
.clear {
|
||||
font-size: 12px;
|
||||
margin-left: 15px;
|
||||
color: #40a9ff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.collapse {
|
||||
font-size: 12px;
|
||||
margin-top: 15px;
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
.select-count {
|
||||
font-weight: 600;
|
||||
color: #40a9ff;
|
||||
}
|
||||
}
|
||||
|
||||
.my-drawer-footer {
|
||||
z-index: 10;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
border-top: 1px solid #e8e8e8;
|
||||
padding: 10px 16px;
|
||||
text-align: right;
|
||||
background: #fff;
|
||||
}
|
||||
</style>
|
||||
@@ -1,284 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<div id="toolbar">
|
||||
<button class="ql-bold" title="粗体"></button>
|
||||
<button class="ql-italic" title="斜体"></button>
|
||||
<button class="ql-underline" title="下划线"></button>
|
||||
<button class="ql-strike" title="删除线"></button>
|
||||
<select class="ql-size" title="字体大小">
|
||||
<option value="small"></option>
|
||||
<option selected></option>
|
||||
<option value="large"></option>
|
||||
<option value="huge"></option>
|
||||
</select>
|
||||
<select class="ql-header" title="标题大小">
|
||||
<option value="1"></option>
|
||||
<option value="2"></option>
|
||||
<option value="3"></option>
|
||||
<option value="4"></option>
|
||||
<option value="5"></option>
|
||||
<option value="6"></option>
|
||||
<option selected></option>
|
||||
</select>
|
||||
<select class="ql-font" title="字体"></select>
|
||||
<select class="ql-align" title="对齐方式"></select>
|
||||
<select class="ql-color" title="字体颜色"></select>
|
||||
<select class="ql-background" title="背景颜色"></select>
|
||||
<button class="ql-blockquote" title="引用"></button>
|
||||
<button class="ql-code-block" title="代码块"></button>
|
||||
<button class="ql-list" value="ordered" title="数字列表"></button>
|
||||
<button class="ql-list" value="bullet" title="点列表"></button>
|
||||
<button class="ql-script" value="sub" title="右下标"></button>
|
||||
<button class="ql-script" value="super" title="右上标"></button>
|
||||
<button class="ql-indent" value="-1" title="向左缩进"></button>
|
||||
<button class="ql-indent" value="+1" title="向右缩进"></button>
|
||||
<button class="ql-clean" title="清空样式"></button>
|
||||
|
||||
<button class="ql-link" title="链接"></button>
|
||||
<button class="ql-image" title="插入图片" v-if="base64"></button>
|
||||
<div class="q-menu" title="插入图片" v-if="!base64">
|
||||
<Upload
|
||||
:action="uploadFileUrl"
|
||||
:headers="accessToken"
|
||||
:on-success="handleSuccess"
|
||||
:on-error="handleError"
|
||||
:format="['jpg','jpeg','png','gif','bmp']"
|
||||
accept=".jpg, .jpeg, .png, .gif, .bmp"
|
||||
:max-size="5120"
|
||||
:on-format-error="handleFormatError"
|
||||
:on-exceeded-size="handleMaxSize"
|
||||
:before-upload="beforeUpload"
|
||||
:show-upload-list="false"
|
||||
ref="qup"
|
||||
>
|
||||
<Icon type="md-images" size="20" />
|
||||
</Upload>
|
||||
</div>
|
||||
<button class="ql-video" title="插入视频链接"></button>
|
||||
<div class="q-menu" title="编辑HTML代码" @click="editHTML" v-if="expandHtml">
|
||||
<Icon type="md-code-working" size="22" />
|
||||
</div>
|
||||
<div class="q-menu" title="预览" @click="fullscreenModal=true" v-if="expandPreview">
|
||||
<Icon type="ios-eye" size="24" />
|
||||
</div>
|
||||
<div class="q-menu q-trash" title="清空" @click="clear" v-if="expandClear">
|
||||
<Icon type="md-trash" size="18" style="display: block;" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div :id="id" :style="{minHeight: minHeight}"></div>
|
||||
|
||||
<Modal
|
||||
title="编辑html代码"
|
||||
v-model="showHTMLModal"
|
||||
:mask-closable="false"
|
||||
:width="900"
|
||||
:fullscreen="full"
|
||||
>
|
||||
<Input
|
||||
v-if="!full"
|
||||
v-model="dataEdit"
|
||||
:rows="15"
|
||||
type="textarea"
|
||||
style="max-height:60vh;overflow:auto;"
|
||||
/>
|
||||
<Input v-if="full" v-model="dataEdit" :rows="32" type="textarea" />
|
||||
<div slot="footer">
|
||||
<Button @click="full=!full" icon="md-expand">全屏开/关</Button>
|
||||
<Button @click="editHTMLOk" type="primary" icon="md-checkmark-circle-outline">确定保存</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
<Modal title="预览" v-model="fullscreenModal" fullscreen>
|
||||
<div v-html="data">{{data}}</div>
|
||||
<div slot="footer">
|
||||
<Button @click="fullscreenModal=false">关闭</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { uploadFile } from "@/api/index";
|
||||
import Quill from "quill";
|
||||
import "quill/dist/quill.snow.css";
|
||||
import xss from "xss";
|
||||
var editor = null;
|
||||
export default {
|
||||
name: "editor",
|
||||
props: {
|
||||
id: {
|
||||
type: String,
|
||||
default: "quill"
|
||||
},
|
||||
value: String,
|
||||
base64: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
minHeight: {
|
||||
type: String,
|
||||
default: "300px"
|
||||
},
|
||||
expandHtml: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
expandPreview: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
expandClear: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
openXss: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
accessToken: {}, // 验证token
|
||||
uploadFileUrl: uploadFile, // 上传地址
|
||||
editor: null, // 富文本初始化
|
||||
options: { // 富文本配置
|
||||
theme: "snow",
|
||||
modules: {
|
||||
toolbar: "#toolbar"
|
||||
},
|
||||
placeholder: "在这输入内容 ..."
|
||||
},
|
||||
data: this.value, // 富文本数据
|
||||
dataEdit: "", // 编辑数据
|
||||
showHTMLModal: false, // 显示html
|
||||
full: false, // html全屏开关
|
||||
fullscreenModal: false // 显示全屏预览
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
initEditor() {
|
||||
this.accessToken = {
|
||||
accessToken: this.getStore("accessToken")
|
||||
};
|
||||
editor = new Quill(`#${this.id}`, this.options);
|
||||
let that = this;
|
||||
if (this.value) {
|
||||
editor.pasteHTML(this.value);
|
||||
}
|
||||
editor.on("text-change", function(delta, oldDelta, source) {
|
||||
let html = editor.container.firstChild.innerHTML;
|
||||
if (that.openXss) {
|
||||
that.data = xss(html);
|
||||
} else {
|
||||
that.data = html;
|
||||
}
|
||||
that.$emit("input", that.data);
|
||||
that.$emit("on-change", that.data);
|
||||
});
|
||||
},
|
||||
handleFormatError(file) {
|
||||
this.$Notice.warning({
|
||||
title: "不支持的文件格式",
|
||||
desc:
|
||||
"所选文件‘ " +
|
||||
file.name +
|
||||
" ’格式不正确, 请选择 .jpg .jpeg .png .gif .bmp格式文件"
|
||||
});
|
||||
},
|
||||
handleMaxSize(file) {
|
||||
this.$Notice.warning({
|
||||
title: "文件大小过大",
|
||||
desc: "所选文件‘ " + file.name + " ’大小过大, 不得超过 5M."
|
||||
});
|
||||
},
|
||||
beforeUpload() {
|
||||
return true;
|
||||
},
|
||||
handleSuccess(res, file) {
|
||||
if (res.success) {
|
||||
let url = res.result;
|
||||
// 获取光标位置
|
||||
let range = editor.getSelection(true);
|
||||
// 总元素
|
||||
let delta = editor.getContents().length;
|
||||
let index;
|
||||
if (range) {
|
||||
index = range.index;
|
||||
} else {
|
||||
index = delta;
|
||||
}
|
||||
// 插入元素
|
||||
editor.insertEmbed(index, "image", url);
|
||||
editor.setSelection(index + 1, 0);
|
||||
} else {
|
||||
this.$Message.error(res.message);
|
||||
}
|
||||
},
|
||||
handleError(error, file, fileList) {
|
||||
this.$Message.error(error.toString());
|
||||
},
|
||||
editHTML() {
|
||||
this.dataEdit = this.data;
|
||||
this.showHTMLModal = true;
|
||||
},
|
||||
editHTMLOk() {
|
||||
editor.pasteHTML(this.dataEdit);
|
||||
this.$emit("input", this.data);
|
||||
this.$emit("on-change", this.data);
|
||||
this.showHTMLModal = false;
|
||||
},
|
||||
clear() {
|
||||
this.$Modal.confirm({
|
||||
title: "确认清空",
|
||||
content: "确认要清空编辑器内容?清空后不能撤回",
|
||||
onOk: () => {
|
||||
this.data = "";
|
||||
editor.pasteHTML(this.data);
|
||||
this.$emit("input", this.data);
|
||||
this.$emit("on-change", this.data);
|
||||
}
|
||||
});
|
||||
},
|
||||
setData(value) {
|
||||
if (!editor) {
|
||||
this.initEditor();
|
||||
}
|
||||
if (value && value != this.data) {
|
||||
this.data = value;
|
||||
let index = editor.selection.savedRange.index;
|
||||
editor.pasteHTML(this.data);
|
||||
editor.setSelection(index, 0);
|
||||
this.$emit("input", this.data);
|
||||
this.$emit("on-change", this.data);
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
value(val) {
|
||||
this.setData(val);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initEditor();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.q-menu {
|
||||
margin: 0 3px;
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
color: #444;
|
||||
:hover {
|
||||
color: #06c;
|
||||
}
|
||||
}
|
||||
.q-trash {
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
.ql-tooltip {
|
||||
left: 30% !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
<template>
|
||||
<div class="spinner">
|
||||
<div class="rect1"></div>
|
||||
<div class="rect2"></div>
|
||||
<div class="rect3"></div>
|
||||
<div class="rect4"></div>
|
||||
<div class="rect5"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "rectLoading"
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.spinner {
|
||||
margin-top: 20vh;
|
||||
margin-bottom: 30vh;
|
||||
height: 60px;
|
||||
text-align: center;
|
||||
font-size: 10px;
|
||||
span {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
margin-top: 1vh;
|
||||
}
|
||||
div {
|
||||
margin-right: 4px;
|
||||
background-color: #4e9ff5;
|
||||
height: 100%;
|
||||
width: 6px;
|
||||
display: inline-block;
|
||||
-webkit-animation: stretchdelay 1.2s infinite ease-in-out;
|
||||
animation: stretchdelay 1.2s infinite ease-in-out;
|
||||
}
|
||||
.rect2 {
|
||||
-webkit-animation-delay: -1.1s;
|
||||
animation-delay: -1.1s;
|
||||
}
|
||||
.rect3 {
|
||||
-webkit-animation-delay: -1s;
|
||||
animation-delay: -1s;
|
||||
}
|
||||
.rect4 {
|
||||
-webkit-animation-delay: -0.9s;
|
||||
animation-delay: -0.9s;
|
||||
}
|
||||
.rect5 {
|
||||
-webkit-animation-delay: -0.8s;
|
||||
animation-delay: -0.8s;
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes stretchdelay {
|
||||
0%,
|
||||
40%,
|
||||
100% {
|
||||
-webkit-transform: scaleY(0.4);
|
||||
}
|
||||
20% {
|
||||
-webkit-transform: scaleY(1);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes stretchdelay {
|
||||
0%,
|
||||
40%,
|
||||
100% {
|
||||
transform: scaleY(0.4);
|
||||
-webkit-transform: scaleY(0.4);
|
||||
}
|
||||
20% {
|
||||
transform: scaleY(1);
|
||||
-webkit-transform: scaleY(1);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -108,11 +108,13 @@ export default {
|
||||
this.strengthValue = 100;
|
||||
}
|
||||
},
|
||||
// 密码变动后回调
|
||||
handleChange(v) {
|
||||
this.strengthChange();
|
||||
this.$emit("input", this.currentValue);
|
||||
this.$emit("on-change", this.currentValue, this.grade, this.strength);
|
||||
},
|
||||
// 监听密码变动,实时回显密码强度
|
||||
setCurrentValue(value) {
|
||||
if (value === this.currentValue) {
|
||||
return;
|
||||
|
||||
@@ -1,358 +0,0 @@
|
||||
<template>
|
||||
<div class="sku-choose">
|
||||
<Button @click="showDrawer=true" :icon="icon">{{text}}</Button>
|
||||
<span @click="clearSelectData" class="clear">清空已选</span>
|
||||
<Collapse simple class="collapse">
|
||||
<Panel name="1">
|
||||
已选择
|
||||
<span class="select-count">{{selectObj.length}}</span> 件
|
||||
<p slot="content">
|
||||
<Tag
|
||||
v-for="(item, i) in selectObj"
|
||||
:key="i"
|
||||
:name="item.id"
|
||||
color="default"
|
||||
closable
|
||||
@on-close="handleCancelObj"
|
||||
>{{createName(item)}}
|
||||
</Tag>
|
||||
</p>
|
||||
</Panel>
|
||||
</Collapse>
|
||||
<Drawer title="选择SKU" closable v-model="showDrawer" :width="width" draggable>
|
||||
<Form ref="searchForm" :model="searchForm" inline :label-width="55">
|
||||
<Form-item label="名称" prop="goodsName">
|
||||
<Input
|
||||
type="text"
|
||||
v-model="searchForm.goodsName"
|
||||
clearable
|
||||
placeholder="输入商品名称"
|
||||
style="width: 200px"
|
||||
/>
|
||||
</Form-item>
|
||||
<Form-item style="margin-left:-35px;" class="br">
|
||||
<Button @click="handleSearchData" type="primary" icon="ios-search">搜索</Button>
|
||||
<Button @click="handleResetObj">重置</Button>
|
||||
</Form-item>
|
||||
</Form>
|
||||
<Table
|
||||
:loading="showLoading"
|
||||
border
|
||||
:columns="tableColumns"
|
||||
:data="tableData"
|
||||
:height="height"
|
||||
ref="tableData"
|
||||
></Table>
|
||||
<Row type="flex" justify="end" style="margin: 10px 0;">
|
||||
<Page
|
||||
:current="searchForm.pageNumber"
|
||||
:total="tableTotal"
|
||||
:page-size="searchForm.pageSize"
|
||||
@on-change="changeDataPage"
|
||||
@on-page-size-change="changeDataPageSize"
|
||||
:page-size-opts="[10,20,50]"
|
||||
size="small"
|
||||
show-total
|
||||
show-elevator
|
||||
show-sizer
|
||||
></Page>
|
||||
</Row>
|
||||
<div class="my-drawer-footer">
|
||||
已选择
|
||||
<span class="select-count">{{selectObj.length}}</span> 件
|
||||
<Button @click="clearSelectData" style="margin-left:10px">清空已选</Button>
|
||||
<Button @click="showDrawer=false" type="primary" style="margin-left:10px">关闭</Button>
|
||||
</div>
|
||||
</Drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {getSkuPage} from "@/api/goods";
|
||||
|
||||
export default {
|
||||
name: "userChoose",
|
||||
props: {
|
||||
text: {
|
||||
type: String,
|
||||
default: "选择SKU"
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
default: "md-basket"
|
||||
},
|
||||
initData: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
createName: {
|
||||
type: Function,
|
||||
default: function (item) {
|
||||
return item.goodsName
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
this.selectObj = this.initData
|
||||
console.log(JSON.stringify(this.initData))
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
//默认值后续计算
|
||||
height: 500,
|
||||
width: 500,
|
||||
//加载状态
|
||||
showLoading: true,
|
||||
//展示抽屉
|
||||
showDrawer: false,
|
||||
selectObj: [], // 选择数据
|
||||
searchForm: { // 请求参数
|
||||
goodsName: "",
|
||||
pageNumber: 1, // 当前页数
|
||||
pageSize: 10, // 页面大小
|
||||
sort: "createTime", // 默认排序字段
|
||||
order: "desc" // 默认排序方式
|
||||
},
|
||||
tableColumns: [ // 表头
|
||||
{
|
||||
type: "index",
|
||||
width: 60,
|
||||
align: "center"
|
||||
},
|
||||
{
|
||||
title: "商品名称",
|
||||
key: "goodsName",
|
||||
minWidth: 140
|
||||
},
|
||||
{
|
||||
title: "规格",
|
||||
key: "specName",
|
||||
minWidth: 140,
|
||||
},
|
||||
{
|
||||
title: "图片",
|
||||
key: "thumbnail",
|
||||
width: 80,
|
||||
align: "center",
|
||||
render: (h, params) => {
|
||||
return h("Avatar", {
|
||||
props: {
|
||||
src: params.row.face
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
key: "status",
|
||||
align: "center",
|
||||
width: 120,
|
||||
render: (h, params) => {
|
||||
if (params.row.delFlag == 0) {
|
||||
return h("div", [
|
||||
h("Badge", {
|
||||
props: {
|
||||
status: "success",
|
||||
text: "正常"
|
||||
}
|
||||
})
|
||||
]);
|
||||
} else if (params.row.delFlag == -1) {
|
||||
return h("div", [
|
||||
h("Badge", {
|
||||
props: {
|
||||
status: "error",
|
||||
text: "禁用"
|
||||
}
|
||||
})
|
||||
]);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "创建时间",
|
||||
key: "createTime",
|
||||
sortable: true,
|
||||
sortType: "desc",
|
||||
width: 170
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
key: "action",
|
||||
width: 130,
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
render: (h, params) => {
|
||||
let select;
|
||||
this.selectObj.forEach(item => {
|
||||
if (item.id === params.row.id) {
|
||||
select = params.row
|
||||
}
|
||||
});
|
||||
|
||||
if (select) {
|
||||
return h("div", [
|
||||
h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "info",
|
||||
size: "small"
|
||||
},
|
||||
on: {
|
||||
click: () => {
|
||||
this.chooseCancel(params.row);
|
||||
}
|
||||
}
|
||||
},
|
||||
"取消选择"
|
||||
)
|
||||
]);
|
||||
} else {
|
||||
return h("div", [
|
||||
h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "info",
|
||||
size: "small"
|
||||
},
|
||||
on: {
|
||||
click: () => {
|
||||
this.chooseObj(params.row);
|
||||
}
|
||||
}
|
||||
},
|
||||
"选择"
|
||||
)
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
tableData: [], // 表格数据
|
||||
tableTotal: 0 // 总数
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
changeDataPage(v) {
|
||||
this.searchForm.pageNumber = v;
|
||||
this.searchData();
|
||||
},
|
||||
changeDataPageSize(v) {
|
||||
this.searchForm.pageSize = v;
|
||||
this.searchData();
|
||||
},
|
||||
searchData() {
|
||||
this.showLoading = true;
|
||||
getSkuPage(this.searchForm).then(res => {
|
||||
this.showLoading = false;
|
||||
if (res.success) {
|
||||
this.tableData = res.result.records;
|
||||
this.tableTotal = res.result.total;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
handleSearchData() {
|
||||
this.searchForm.pageNumber = 1;
|
||||
this.searchForm.pageSize = 10;
|
||||
this.searchData();
|
||||
},
|
||||
handleResetObj() {
|
||||
this.$refs.searchForm.resetFields();
|
||||
this.searchForm.pageNumber = 1;
|
||||
this.searchForm.pageSize = 9;
|
||||
this.searchForm.departmentId = "";
|
||||
// 重新加载数据
|
||||
this.searchData();
|
||||
},
|
||||
setData(v) {
|
||||
this.selectObj = v;
|
||||
this.$emit("on-change", this.selectObj);
|
||||
},
|
||||
chooseCancel(v) {
|
||||
let _index;
|
||||
this.selectObj.forEach((e, index) => {
|
||||
if (v.id == e.id) {
|
||||
_index = index;
|
||||
}
|
||||
});
|
||||
|
||||
if (_index || _index == 0) {
|
||||
this.selectObj.splice(_index, 1);
|
||||
this.$emit("on-change", this.selectObj);
|
||||
}
|
||||
},
|
||||
chooseObj(v) {
|
||||
// 去重
|
||||
let that = this;
|
||||
let flag = true;
|
||||
this.selectObj.forEach(e => {
|
||||
if (v.id == e.id) {
|
||||
flag = false;
|
||||
}
|
||||
});
|
||||
if (flag) {
|
||||
this.selectObj.push(v);
|
||||
this.$emit("on-change", this.selectObj);
|
||||
}
|
||||
},
|
||||
clearSelectData() {
|
||||
this.selectObj = [];
|
||||
this.$emit("on-change", this.selectObj);
|
||||
},
|
||||
handleCancelObj(e, id) {
|
||||
// 删除所选用户
|
||||
let newArray = [];
|
||||
this.selectObj.forEach(e => {
|
||||
if (id != e.id) {
|
||||
newArray.push(e);
|
||||
}
|
||||
});
|
||||
this.selectObj = newArray;
|
||||
this.$emit("on-change", this.selectObj);
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// 计算高度
|
||||
this.height = Number(document.documentElement.clientHeight - 230);
|
||||
this.width = Number(document.documentElement.clientWidth/2)>900?900:Number(document.documentElement.clientWidth/2)
|
||||
this.searchData();
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.sku-choose {
|
||||
.clear {
|
||||
font-size: 12px;
|
||||
margin-left: 15px;
|
||||
color: #40a9ff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.collapse {
|
||||
font-size: 12px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.select-count {
|
||||
font-weight: 600;
|
||||
color: #40a9ff;
|
||||
}
|
||||
}
|
||||
|
||||
.my-drawer-footer {
|
||||
z-index: 10;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
border-top: 1px solid #e8e8e8;
|
||||
padding: 10px 16px;
|
||||
text-align: right;
|
||||
background: #fff;
|
||||
}
|
||||
</style>
|
||||
@@ -91,27 +91,30 @@ export default {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
// 拖拽结束事件
|
||||
onEnd() {
|
||||
this.returnValue();
|
||||
},
|
||||
// 初始化方法
|
||||
init() {
|
||||
this.setData(this.value, true);
|
||||
this.accessToken = {
|
||||
accessToken: this.getStore("accessToken")
|
||||
};
|
||||
},
|
||||
// 预览图片
|
||||
handleView(imgUrl) {
|
||||
this.imgUrl = imgUrl;
|
||||
this.viewImage = true;
|
||||
},
|
||||
// 移除图片
|
||||
handleRemove(file) {
|
||||
this.uploadList = this.uploadList.filter(i => i.url !== file.url);
|
||||
this.returnValue();
|
||||
},
|
||||
// 上传成功
|
||||
handleSuccess(res, file) {
|
||||
if (res.success) {
|
||||
|
||||
|
||||
file.url = res.result;
|
||||
// 单张图片处理
|
||||
if (!this.multiple && this.uploadList.length > 0) {
|
||||
@@ -122,12 +125,14 @@ export default {
|
||||
// 返回组件值
|
||||
this.returnValue();
|
||||
} else {
|
||||
// this.$Message.error(res.message);
|
||||
this.$Message.error(res.message);
|
||||
}
|
||||
},
|
||||
// 上传失败
|
||||
handleError(error, file, fileList) {
|
||||
this.$Message.error(error.toString());
|
||||
},
|
||||
// 格式校验
|
||||
handleFormatError(file) {
|
||||
this.$Notice.warning({
|
||||
title: "不支持的文件格式",
|
||||
@@ -137,6 +142,7 @@ export default {
|
||||
" ’格式不正确, 请选择 .jpg .jpeg .png .gif图片格式文件"
|
||||
});
|
||||
},
|
||||
// 上传文件大小校验
|
||||
handleMaxSize(file) {
|
||||
this.$Notice.warning({
|
||||
title: "文件大小过大",
|
||||
@@ -148,6 +154,7 @@ export default {
|
||||
"M."
|
||||
});
|
||||
},
|
||||
// 上传之前钩子
|
||||
handleBeforeUpload() {
|
||||
if (this.multiple && this.uploadList.length >= this.limit) {
|
||||
this.$Message.warning("最多只能上传" + this.limit + "张图片");
|
||||
@@ -155,6 +162,7 @@ export default {
|
||||
}
|
||||
return true;
|
||||
},
|
||||
// 返回组件值
|
||||
returnValue() {
|
||||
if (!this.uploadList || this.uploadList.length < 1) {
|
||||
if (!this.multiple) {
|
||||
@@ -180,6 +188,7 @@ export default {
|
||||
this.$emit("on-change", v);
|
||||
}
|
||||
},
|
||||
// 传入值变化时改变值
|
||||
setData(v, init) {
|
||||
if (typeof v == "string") {
|
||||
// 单张
|
||||
|
||||
@@ -1,352 +0,0 @@
|
||||
<template>
|
||||
<div class="user-choose">
|
||||
<Button @click="userModalVisible=true" :icon="icon">{{text}}</Button>
|
||||
<span @click="clearSelectData" class="clear">清空已选</span>
|
||||
<Collapse simple class="collapse">
|
||||
<Panel name="1">
|
||||
已选择
|
||||
<span class="select-count">{{selectUsers.length}}</span> 人
|
||||
<p slot="content">
|
||||
<Tag
|
||||
v-for="(item, i) in selectUsers"
|
||||
:key="i"
|
||||
:name="item.id"
|
||||
color="default"
|
||||
closable
|
||||
@on-close="handleCancelUser"
|
||||
>{{item.username}}</Tag>
|
||||
</p>
|
||||
</Panel>
|
||||
</Collapse>
|
||||
<Drawer title="选择用户" closable v-model="userModalVisible" width="800" draggable>
|
||||
<Form ref="searchUserForm" :model="searchUserForm" inline :label-width="55">
|
||||
<Form-item label="用户名" prop="username">
|
||||
<Input
|
||||
type="text"
|
||||
v-model="searchUserForm.username"
|
||||
clearable
|
||||
placeholder="请输入用户名"
|
||||
style="width: 200px"
|
||||
/>
|
||||
</Form-item>
|
||||
<Form-item label="部门" prop="department">
|
||||
<department-choose @on-change="handleSelectDep" style="width: 200px" ref="dep"></department-choose>
|
||||
</Form-item>
|
||||
<Form-item style="margin-left:-35px;" class="br">
|
||||
<Button @click="handleSearchUser" type="primary" icon="ios-search">搜索</Button>
|
||||
<Button @click="handleResetUser">重置</Button>
|
||||
</Form-item>
|
||||
</Form>
|
||||
<Table
|
||||
:loading="userLoading"
|
||||
border
|
||||
:columns="userColumns"
|
||||
:data="userData"
|
||||
:height="height"
|
||||
ref="userTable"
|
||||
></Table>
|
||||
<Row type="flex" justify="end" style="margin: 10px 0;">
|
||||
<Page
|
||||
:current="searchUserForm.pageNumber"
|
||||
:total="totalUser"
|
||||
:page-size="searchUserForm.pageSize"
|
||||
@on-change="changeUserPage"
|
||||
@on-page-size-change="changeUserPageSize"
|
||||
:page-size-opts="[10,20,50]"
|
||||
size="small"
|
||||
show-total
|
||||
show-elevator
|
||||
show-sizer
|
||||
></Page>
|
||||
</Row>
|
||||
<div class="my-drawer-footer">
|
||||
已选择
|
||||
<span class="select-count">{{selectUsers.length}}</span> 人
|
||||
<Button @click="clearSelectData" style="margin-left:10px">清空已选</Button>
|
||||
<Button @click="userModalVisible=false" type="primary" style="margin-left:10px">关闭</Button>
|
||||
</div>
|
||||
</Drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getUserListData } from "@/api/index";
|
||||
import departmentChoose from "./department-choose";
|
||||
export default {
|
||||
name: "userChoose",
|
||||
components: {
|
||||
departmentChoose
|
||||
},
|
||||
props: {
|
||||
text: {
|
||||
type: String,
|
||||
default: "选择用户"
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
default: "md-person-add"
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
//高度 下方已重新计算
|
||||
height: 500,
|
||||
//加载
|
||||
userLoading: true,
|
||||
//显示选择器
|
||||
userModalVisible: false,
|
||||
//选择的对象
|
||||
selectUsers: [],
|
||||
//搜索参数
|
||||
searchUserForm: {
|
||||
username: "",
|
||||
type: "",
|
||||
status: "",
|
||||
pageNumber: 1, // 当前页数
|
||||
pageSize: 10, // 页面大小
|
||||
sort: "createTime", // 默认排序字段
|
||||
order: "desc" // 默认排序方式
|
||||
},
|
||||
userColumns: [
|
||||
{
|
||||
type: "index",
|
||||
width: 60,
|
||||
align: "center"
|
||||
},
|
||||
{
|
||||
title: "用户名",
|
||||
key: "username",
|
||||
minWidth: 140,
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
title: "头像",
|
||||
key: "avatar",
|
||||
width: 80,
|
||||
align: "center",
|
||||
render: (h, params) => {
|
||||
return h("Avatar", {
|
||||
props: {
|
||||
src: params.row.avatar
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "所属部门",
|
||||
key: "departmentTitle",
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: "手机",
|
||||
key: "mobile",
|
||||
width: 125,
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
title: "邮箱",
|
||||
key: "email",
|
||||
width: 180,
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
title: "性别",
|
||||
key: "sex",
|
||||
width: 70,
|
||||
align: "center"
|
||||
},
|
||||
{
|
||||
title: "用户类型",
|
||||
key: "type",
|
||||
align: "center",
|
||||
width: 100,
|
||||
render: (h, params) => {
|
||||
let re = "";
|
||||
if (params.row.type == 1) {
|
||||
re = "管理员";
|
||||
} else if (params.row.type == 0) {
|
||||
re = "普通用户";
|
||||
}
|
||||
return h("div", re);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
key: "status",
|
||||
align: "center",
|
||||
width: 120,
|
||||
render: (h, params) => {
|
||||
if (params.row.status == 0) {
|
||||
return h("div", [
|
||||
h("Badge", {
|
||||
props: {
|
||||
status: "success",
|
||||
text: "正常启用"
|
||||
}
|
||||
})
|
||||
]);
|
||||
} else if (params.row.status == -1) {
|
||||
return h("div", [
|
||||
h("Badge", {
|
||||
props: {
|
||||
status: "error",
|
||||
text: "禁用"
|
||||
}
|
||||
})
|
||||
]);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "创建时间",
|
||||
key: "createTime",
|
||||
sortable: true,
|
||||
sortType: "desc",
|
||||
width: 170
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
key: "action",
|
||||
width: 130,
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
render: (h, params) => {
|
||||
return h("div", [
|
||||
h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "info",
|
||||
size: "small"
|
||||
},
|
||||
on: {
|
||||
click: () => {
|
||||
this.chooseUser(params.row);
|
||||
}
|
||||
}
|
||||
},
|
||||
"添加该用户"
|
||||
)
|
||||
]);
|
||||
}
|
||||
}
|
||||
],
|
||||
userData: [], // 表格数据
|
||||
totalUser: 0 // 总数
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
handleSelectDep(v) {
|
||||
this.searchUserForm.departmentId = v;
|
||||
},
|
||||
changeUserPage(v) {
|
||||
this.searchUserForm.pageNumber = v;
|
||||
this.getUserDataList();
|
||||
},
|
||||
changeUserPageSize(v) {
|
||||
this.searchUserForm.pageSize = v;
|
||||
this.getUserDataList();
|
||||
},
|
||||
getUserDataList() {
|
||||
this.userLoading = true;
|
||||
getUserListData(this.searchUserForm).then(res => {
|
||||
this.userLoading = false;
|
||||
if (res.success) {
|
||||
this.userData = res.result.records;
|
||||
this.totalUser = res.result.total;
|
||||
}
|
||||
});
|
||||
},
|
||||
handleSearchUser() {
|
||||
this.searchUserForm.pageNumber = 1;
|
||||
this.searchUserForm.pageSize = 9;
|
||||
this.getUserDataList();
|
||||
},
|
||||
handleResetUser() {
|
||||
this.$refs.searchUserForm.resetFields();
|
||||
this.searchUserForm.pageNumber = 1;
|
||||
this.searchUserForm.pageSize = 9;
|
||||
this.$refs.dep.clearSelect();
|
||||
this.searchUserForm.departmentId = "";
|
||||
// 重新加载数据
|
||||
this.getUserDataList();
|
||||
},
|
||||
setData(v) {
|
||||
this.selectUsers = v;
|
||||
this.$emit("on-change", this.selectUsers);
|
||||
},
|
||||
chooseUser(v) {
|
||||
// 去重
|
||||
let that = this;
|
||||
let flag = true;
|
||||
this.selectUsers.forEach(e => {
|
||||
if (v.id == e.id) {
|
||||
that.$Message.warning("已经添加过啦,请勿重复选择");
|
||||
flag = false;
|
||||
}
|
||||
});
|
||||
if (flag) {
|
||||
let u = {
|
||||
id: v.id,
|
||||
username: v.username
|
||||
};
|
||||
this.selectUsers.push(u);
|
||||
this.$emit("on-change", this.selectUsers);
|
||||
this.$Message.success(`添加用户 ${v.username} 成功`);
|
||||
}
|
||||
},
|
||||
clearSelectData() {
|
||||
this.selectUsers = [];
|
||||
this.$emit("on-change", this.selectUsers);
|
||||
},
|
||||
handleCancelUser(e, id) {
|
||||
// 删除所选用户
|
||||
let newArray = [];
|
||||
this.selectUsers.forEach(e => {
|
||||
if (id != e.id) {
|
||||
newArray.push(e);
|
||||
}
|
||||
});
|
||||
this.selectUsers = newArray;
|
||||
this.$emit("on-change", this.selectUsers);
|
||||
this.$Message.success("删除所选用户成功");
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// 计算高度
|
||||
this.height = Number(document.documentElement.clientHeight - 230);
|
||||
this.getUserDataList();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.user-choose {
|
||||
.clear {
|
||||
font-size: 12px;
|
||||
margin-left: 15px;
|
||||
color: #40a9ff;
|
||||
cursor: pointer;
|
||||
}
|
||||
.collapse {
|
||||
font-size: 12px;
|
||||
margin-top: 15px;
|
||||
width: 500px;
|
||||
}
|
||||
.select-count {
|
||||
font-weight: 600;
|
||||
color: #40a9ff;
|
||||
}
|
||||
}
|
||||
.my-drawer-footer {
|
||||
z-index: 10;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
border-top: 1px solid #e8e8e8;
|
||||
padding: 10px 16px;
|
||||
text-align: right;
|
||||
background: #fff;
|
||||
}
|
||||
</style>
|
||||
@@ -1,184 +1,184 @@
|
||||
<template>
|
||||
<div class="map">
|
||||
<Modal
|
||||
v-model="showMap"
|
||||
title="选择地址"
|
||||
width="800"
|
||||
>
|
||||
<div class="address">{{addrContent.address}}</div>
|
||||
<div id="map-container"></div>
|
||||
<Modal v-model="showMap" title="选择地址" width="800">
|
||||
<div class="address">{{ addrContent.address }}</div>
|
||||
<div id="map-container"></div>
|
||||
|
||||
<div class="search-con">
|
||||
<Input placeholder="输入关键字搜索" id="input-map" v-model="mapSearch"/>
|
||||
<ul>
|
||||
<li v-for="(tip, index) in tips" :key="index" @click="selectAddr(tip.location)">
|
||||
<p>{{tip.name}}</p>
|
||||
<p>{{tip.district + tip.address}}</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div slot="footer">
|
||||
<Button type="default" @click="showMap = false">取消</Button>
|
||||
<Button type="primary" :loading="loading" @click="ok">确定</Button>
|
||||
</div>
|
||||
<div class="search-con">
|
||||
<Input
|
||||
placeholder="输入关键字搜索"
|
||||
id="input-map"
|
||||
v-model="mapSearch"
|
||||
/>
|
||||
<ul>
|
||||
<li
|
||||
v-for="(tip, index) in tips"
|
||||
:key="index"
|
||||
@click="selectAddr(tip.location)"
|
||||
>
|
||||
<p>{{ tip.name }}</p>
|
||||
<p>{{ tip.district + tip.address }}</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div slot="footer">
|
||||
<Button type="default" @click="showMap = false">取消</Button>
|
||||
<Button type="primary" :loading="loading" @click="ok">确定</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import AMapLoader from '@amap/amap-jsapi-loader';
|
||||
import {getRegion} from '@/api/common.js'
|
||||
import AMapLoader from "@amap/amap-jsapi-loader";
|
||||
import { getRegion } from "@/api/common.js";
|
||||
export default {
|
||||
name:'map',
|
||||
data() {
|
||||
name: "map",
|
||||
data() {
|
||||
return {
|
||||
showMap:false, // modal显隐
|
||||
mapSearch:'', // 地图搜索
|
||||
map:null, // 初始化地图
|
||||
autoComplete:null, // 初始化搜索方法
|
||||
geocoder:null, // 初始化地理、坐标转化
|
||||
positionPicker:null, // 地图拖拽选点
|
||||
tips:[], //搜索关键字列表
|
||||
addrContent:{}, // 回显地址信息
|
||||
loading:false, // 加载状态
|
||||
showMap: false, // modal显隐
|
||||
mapSearch: "", // 地图搜索
|
||||
map: null, // 初始化地图
|
||||
autoComplete: null, // 初始化搜索方法
|
||||
geocoder: null, // 初始化地理、坐标转化
|
||||
positionPicker: null, // 地图拖拽选点
|
||||
tips: [], //搜索关键字列表
|
||||
addrContent: {}, // 回显地址信息
|
||||
loading: false, // 加载状态
|
||||
};
|
||||
},
|
||||
watch:{
|
||||
mapSearch:function(val){
|
||||
this.searchOfMap(val)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
ok(){ // 确定选择
|
||||
|
||||
this.loading = true
|
||||
|
||||
const codeObj = {}
|
||||
const params = {
|
||||
cityCode: this.addrContent.regeocode.addressComponent.citycode,
|
||||
townName: this.addrContent.regeocode.addressComponent.township
|
||||
}
|
||||
getRegion(params).then(res=>{
|
||||
if(res.success) {
|
||||
this.addrContent.addr = res.result.name.replace(/,/g," ")
|
||||
this.addrContent.addrId = res.result.id
|
||||
this.loading = false
|
||||
this.showMap = false;
|
||||
this.$emit('getAddress',this.addrContent);
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
watch: {
|
||||
mapSearch: function (val) {
|
||||
this.searchOfMap(val);
|
||||
},
|
||||
init() {
|
||||
AMapLoader.load({
|
||||
key: "b440952723253aa9fe483e698057bf7d", // 申请好的Web端开发者Key,首次调用 load 时必填
|
||||
version: "", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
|
||||
plugins: [
|
||||
"AMap.ToolBar",
|
||||
"AMap.Autocomplete",
|
||||
"AMap.PlaceSearch",
|
||||
"AMap.Geolocation",
|
||||
'AMap.Geocoder'
|
||||
], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
|
||||
"AMapUI": { // 是否加载 AMapUI,缺省不加载
|
||||
"version": '1.1', // AMapUI 缺省 1.1
|
||||
"plugins":['misc/PositionPicker'], // 需要加载的 AMapUI ui插件
|
||||
},
|
||||
})
|
||||
.then((AMap) => {
|
||||
let that = this;
|
||||
this.map = new AMap.Map("map-container",{
|
||||
zoom:12
|
||||
});
|
||||
that.map.addControl(new AMap.ToolBar());
|
||||
that.map.addControl(new AMap.Autocomplete());
|
||||
that.map.addControl(new AMap.PlaceSearch());
|
||||
that.map.addControl(new AMap.Geocoder());
|
||||
|
||||
// 实例化Autocomplete
|
||||
let autoOptions = {
|
||||
city: "全国"
|
||||
};
|
||||
that.autoComplete = new AMap.Autocomplete(autoOptions); // 搜索
|
||||
that.geocoder = new AMap.Geocoder(autoOptions)
|
||||
|
||||
|
||||
that.positionPicker = new AMapUI.PositionPicker({ // 拖拽选点
|
||||
mode: 'dragMap',
|
||||
map:that.map
|
||||
});
|
||||
that.positionPicker.start()
|
||||
/**
|
||||
*
|
||||
* 所有回显数据,都在positionResult里面
|
||||
* 需要字段可以查找
|
||||
*
|
||||
*/
|
||||
that.positionPicker.on('success', function(positionResult) {
|
||||
|
||||
that.addrContent = positionResult;
|
||||
});
|
||||
|
||||
})
|
||||
.catch((e) => {});
|
||||
},
|
||||
searchOfMap(val) { // 地图搜索
|
||||
let that = this;
|
||||
this.autoComplete.search(val, function (status, result) {
|
||||
// 搜索成功时,result即是对应的匹配数据
|
||||
if(status == 'complete' && result.info == 'OK'){
|
||||
that.tips = result.tips;
|
||||
}else {
|
||||
that.tips = []
|
||||
}
|
||||
});
|
||||
},
|
||||
selectAddr(location) { // 选择坐标
|
||||
if(!location){
|
||||
this.$Message.warning('请选择正确点位')
|
||||
return false;
|
||||
},
|
||||
methods: {
|
||||
ok() {
|
||||
// 确定选择
|
||||
this.loading = true;
|
||||
const params = {
|
||||
cityCode: this.addrContent.regeocode.addressComponent.citycode,
|
||||
townName: this.addrContent.regeocode.addressComponent.township,
|
||||
};
|
||||
getRegion(params).then((res) => {
|
||||
if (res.success) {
|
||||
this.addrContent.addr = res.result.name.replace(/,/g, " ");
|
||||
this.addrContent.addrId = res.result.id;
|
||||
this.loading = false;
|
||||
this.showMap = false;
|
||||
this.$emit("getAddress", this.addrContent);
|
||||
}
|
||||
const lnglat = [location.lng,location.lat]
|
||||
this.positionPicker.start(lnglat)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.init()
|
||||
},
|
||||
});
|
||||
},
|
||||
// 初始化地图组件
|
||||
init() {
|
||||
AMapLoader.load({
|
||||
key: "b440952723253aa9fe483e698057bf7d", // 申请好的Web端开发者Key,首次调用 load 时必填
|
||||
version: "", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
|
||||
plugins: [
|
||||
"AMap.ToolBar",
|
||||
"AMap.Autocomplete",
|
||||
"AMap.PlaceSearch",
|
||||
"AMap.Geolocation",
|
||||
"AMap.Geocoder",
|
||||
], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
|
||||
AMapUI: {
|
||||
// 是否加载 AMapUI,缺省不加载
|
||||
version: "1.1", // AMapUI 缺省 1.1
|
||||
plugins: ["misc/PositionPicker"], // 需要加载的 AMapUI ui插件
|
||||
},
|
||||
}).then((AMap) => {
|
||||
let that = this;
|
||||
this.map = new AMap.Map("map-container", {
|
||||
zoom: 12,
|
||||
});
|
||||
that.map.addControl(new AMap.ToolBar());
|
||||
that.map.addControl(new AMap.Autocomplete());
|
||||
that.map.addControl(new AMap.PlaceSearch());
|
||||
that.map.addControl(new AMap.Geocoder());
|
||||
|
||||
// 实例化Autocomplete
|
||||
let autoOptions = {
|
||||
city: "全国",
|
||||
};
|
||||
that.autoComplete = new AMap.Autocomplete(autoOptions); // 搜索
|
||||
that.geocoder = new AMap.Geocoder(autoOptions);
|
||||
|
||||
that.positionPicker = new AMapUI.PositionPicker({
|
||||
// 拖拽选点
|
||||
mode: "dragMap",
|
||||
map: that.map,
|
||||
});
|
||||
that.positionPicker.start();
|
||||
/**
|
||||
*
|
||||
* 所有回显数据,都在positionResult里面
|
||||
* 需要字段可以查找
|
||||
*
|
||||
*/
|
||||
that.positionPicker.on("success", function (positionResult) {
|
||||
that.addrContent = positionResult;
|
||||
});
|
||||
}).catch((e) => {});
|
||||
},
|
||||
searchOfMap(val) {
|
||||
// 地图搜索
|
||||
let that = this;
|
||||
this.autoComplete.search(val, function (status, result) {
|
||||
// 搜索成功时,result即是对应的匹配数据
|
||||
if (status == "complete" && result.info == "OK") {
|
||||
that.tips = result.tips;
|
||||
} else {
|
||||
that.tips = [];
|
||||
}
|
||||
});
|
||||
},
|
||||
selectAddr(location) {
|
||||
// 选择坐标
|
||||
if (!location) {
|
||||
this.$Message.warning("请选择正确点位");
|
||||
return false;
|
||||
}
|
||||
const lnglat = [location.lng, location.lat];
|
||||
this.positionPicker.start(lnglat);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
#map-container{
|
||||
width: 500px;
|
||||
height: 400px;
|
||||
}
|
||||
#map-container {
|
||||
width: 500px;
|
||||
height: 400px;
|
||||
}
|
||||
|
||||
.search-con{
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
top: 64px;
|
||||
width: 260px;
|
||||
ul{
|
||||
width: 260px;
|
||||
height: 400px;
|
||||
overflow: scroll;
|
||||
li{
|
||||
padding: 5px;
|
||||
p:nth-child(2){
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
&:hover{
|
||||
background-color:#eee;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
.search-con {
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
top: 64px;
|
||||
width: 260px;
|
||||
ul {
|
||||
width: 260px;
|
||||
height: 400px;
|
||||
overflow: scroll;
|
||||
li {
|
||||
padding: 5px;
|
||||
p:nth-child(2) {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
&:hover {
|
||||
background-color: #eee;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.address{
|
||||
margin-bottom: 10px;
|
||||
// color: $theme_color;
|
||||
font-weight: bold;
|
||||
}
|
||||
.address {
|
||||
margin-bottom: 10px;
|
||||
// color: $theme_color;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user