|
@@ -1,610 +0,0 @@
|
|
|
-<template>
|
|
|
- <el-form
|
|
|
- ref="ruleForm"
|
|
|
- v-loading="loading"
|
|
|
- :model="ruleForm"
|
|
|
- status-icon
|
|
|
- :rules="rulesThis"
|
|
|
- label-width="90px"
|
|
|
- class="supplierAdd"
|
|
|
- >
|
|
|
- <el-row>
|
|
|
- <el-col :span="24">
|
|
|
- <div class="supplierAdd-title">基础信息</div>
|
|
|
- </el-col>
|
|
|
- <el-col :span="24" class="clear">
|
|
|
- <div class="supplierAdd-title-left fl">
|
|
|
- <el-form-item
|
|
|
- label="门店主图"
|
|
|
- prop="storeImage"
|
|
|
- :disabled="id == 'view'"
|
|
|
- class="activity-upload"
|
|
|
- >
|
|
|
- <div v-if="ruleForm.storeImage" class="img-find">
|
|
|
- <img
|
|
|
- v-viewer
|
|
|
- :src="ruleForm.storeImage"
|
|
|
- class="avatar hover fl"
|
|
|
- style="width: 40px; height: 40px"
|
|
|
- />
|
|
|
- <i class="el-icon-close img-close" />
|
|
|
- <!-- <el-link
|
|
|
- v-if="type !== 'view'"
|
|
|
- class="fl"
|
|
|
- :underline="false"
|
|
|
- type="warning"
|
|
|
- style="margin: 0 0 0 16px"
|
|
|
- @click="deleteimg()"
|
|
|
- >删除</el-link> -->
|
|
|
- </div>
|
|
|
- <div v-else class="btnupload" style="position: relative">
|
|
|
- <i class="el-icon-plus avatar-uploader-icon" />
|
|
|
- <file-upload
|
|
|
- v-if="type !== 'view'"
|
|
|
- class="Upload"
|
|
|
- :disabled="id == 'view'"
|
|
|
- :accept="'.jpg,.png,.jpeg'"
|
|
|
- :multiple="true"
|
|
|
- :uploadcondition="beforeAvatarUpload"
|
|
|
- @UploadErrorEvent="imgUploadError"
|
|
|
- @UploadSuccessEvent="UploadSuccessEvent"
|
|
|
- />
|
|
|
- </div>
|
|
|
- </el-form-item>
|
|
|
- </div>
|
|
|
- <div class="supplierAdd-title-right fr">
|
|
|
- <el-row>
|
|
|
- <el-col :span="8">
|
|
|
- <el-form-item label="供应商" prop="supplier">
|
|
|
- <el-select
|
|
|
- v-model="ruleForm.supplier"
|
|
|
- style="width: 100%"
|
|
|
- :disabled="type !== 'add' && type !== 'edit'"
|
|
|
- placeholder="供应商"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="item in supplierOptions"
|
|
|
- :key="item.code"
|
|
|
- :label="item.name"
|
|
|
- :value="item.code"
|
|
|
- :disabled="Number(item.status) === 0"
|
|
|
- />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
-
|
|
|
- <el-col :span="8">
|
|
|
- <el-form-item label="门店名称" prop="storeName">
|
|
|
- <el-input
|
|
|
- v-model="ruleForm.storeName"
|
|
|
- style="width: 100%"
|
|
|
- :disabled="type !== 'add' && type !== 'edit'"
|
|
|
- placeholder="门店名称"
|
|
|
- />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
-
|
|
|
- <el-col :span="8">
|
|
|
- <el-form-item label="门店类型" prop="storeType">
|
|
|
- <el-select
|
|
|
- v-model="ruleForm.storeType"
|
|
|
- style="width: 100%"
|
|
|
- :disabled="type !== 'add' && type !== 'edit'"
|
|
|
- placeholder="门店类型"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="item in storeTypeOptions"
|
|
|
- :key="item.id"
|
|
|
- :label="item.name"
|
|
|
- :value="item.id"
|
|
|
- :disabled="Number(item.status) === 0"
|
|
|
- />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- </div>
|
|
|
- </el-col>
|
|
|
-
|
|
|
- <el-col :span="24"><div class="supplierAdd-title">联系人信息</div></el-col>
|
|
|
- <el-col :span="6">
|
|
|
- <el-form-item label="姓名" prop="contactor" label-width="75px">
|
|
|
- <el-input
|
|
|
- v-model="ruleForm.contactor"
|
|
|
- :disabled="type !== 'add' && type !== 'edit'"
|
|
|
- placeholder="姓名"
|
|
|
- maxlength="20"
|
|
|
- />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="6">
|
|
|
- <el-form-item label="手机号" prop="mobile" label-width="75px">
|
|
|
- <el-input
|
|
|
- v-model="ruleForm.mobile"
|
|
|
- :disabled="type !== 'add' && type !== 'edit'"
|
|
|
- placeholder="手机号"
|
|
|
- maxlength="20"
|
|
|
- />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="6">
|
|
|
- <el-form-item label="邮箱" prop="email" label-width="75px">
|
|
|
- <el-input
|
|
|
- v-model="ruleForm.email"
|
|
|
- :disabled="type !== 'add' && type !== 'edit'"
|
|
|
- placeholder="邮箱"
|
|
|
- maxlength="50"
|
|
|
- />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
-
|
|
|
- <el-col :span="6">
|
|
|
- <el-form-item label="职位" prop="position" label-width="75px">
|
|
|
- <el-input
|
|
|
- v-model="ruleForm.position"
|
|
|
- :disabled="type !== 'add' && type !== 'edit'"
|
|
|
- placeholder="职位"
|
|
|
- maxlength="20"
|
|
|
- />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-col :span="24"><div class="supplierAdd-title">门店信息</div></el-col>
|
|
|
- <el-col :span="24">
|
|
|
- <el-form-item label="门店地址" prop="storeAddr">
|
|
|
- <div style="display:flex">
|
|
|
- <el-input :value="toponym" />
|
|
|
- <el-button style="margin-left:10px" type="primary" @click="visible = true">选择地址</el-button>
|
|
|
- </div>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="24" class="flex-end">
|
|
|
- <el-button type="primary" @click="save" size="mini">保存</el-button>
|
|
|
- </el-col>
|
|
|
-
|
|
|
- <map-modal :visible.sync="visible" :toponym="toponym" @save="handleMapSelection" />
|
|
|
- </el-form>
|
|
|
-</template>
|
|
|
-<script>
|
|
|
-import asyncRequest from "@/apis/service/operate/shop";
|
|
|
-import asyncRequestStoreType from "@/apis/service/serviceParam/storeType";
|
|
|
-import asyncRequestSupplier from "@/apis/service/operate/supplier";
|
|
|
-import MapModal from "./mapModal.vue"
|
|
|
-
|
|
|
-import Map from "ol/Map"; //地图初始化
|
|
|
-import * as source from "ol/source";
|
|
|
-import Feature from "ol/Feature";
|
|
|
-import Point from "ol/geom/Point";
|
|
|
-import TileLayer from "ol/layer/Tile";
|
|
|
-import * as olProj from "ol/proj";
|
|
|
-import * as style from "ol/style";
|
|
|
-import * as layer from "ol/layer";
|
|
|
-import "ol/ol.css";
|
|
|
-import View from "ol/View";
|
|
|
-import resToken from "@/mixins/resToken";
|
|
|
-import { formItem } from "../columns";
|
|
|
-import {
|
|
|
- isLicense,
|
|
|
- isMobile,
|
|
|
- isqz,
|
|
|
- isSpecialSymbol,
|
|
|
- hasSpace,
|
|
|
- isAddr,
|
|
|
- validEmail,
|
|
|
-} from "@/utils/validate";
|
|
|
-
|
|
|
-let key = "4c3306473a0aa048196208f774b491a5";
|
|
|
-
|
|
|
-/***
|
|
|
- * @props
|
|
|
- * 供应商 supplier
|
|
|
- * 门店名称 storeName
|
|
|
- * 门店类型 storeType
|
|
|
- * 门店主图 storeImage
|
|
|
- * 门店地址 storeAddr
|
|
|
- * 姓名 contactor
|
|
|
- * 手机号 mobile
|
|
|
- * 电子邮箱 email
|
|
|
- * 职位 position
|
|
|
- */
|
|
|
-export default {
|
|
|
- name: "SupplierAdd",
|
|
|
- mixins: [resToken],
|
|
|
- components:{ MapModal },
|
|
|
- props: ["showModel", "id", "type", "sitem"],
|
|
|
- data() {
|
|
|
- const validatemobile = (rule, value, callback) => {
|
|
|
- if (value === "") {
|
|
|
- callback(new Error("手机号不能为空!"));
|
|
|
- } else {
|
|
|
- if (!isMobile(value)) {
|
|
|
- callback(new Error("手机号格式不正确!"));
|
|
|
- } else {
|
|
|
- callback();
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- const validateAddr = (rule, value, callback) => {
|
|
|
- if (value === "") {
|
|
|
- callback(new Error("详细地址不能为空!"));
|
|
|
- } else {
|
|
|
- if (hasSpace(value)) {
|
|
|
- callback(new Error("不能出现/回车/换行符!"));
|
|
|
- } else if (isSpecialSymbol(value)) {
|
|
|
- callback(new Error("不能使用英文特殊字符!"));
|
|
|
- } else if (isAddr(value)) {
|
|
|
- callback();
|
|
|
- } else {
|
|
|
- callback(new Error("详细地址填写不规范!"));
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- const validateEmail = (rule, value, callback) => {
|
|
|
- if (value === "") {
|
|
|
- callback(new Error("邮箱不能为空!"));
|
|
|
- } else {
|
|
|
- if (!validEmail(value)) {
|
|
|
- callback(new Error("邮箱格式不正确!"));
|
|
|
- } else {
|
|
|
- callback();
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- return {
|
|
|
- visible:false,
|
|
|
- parmValue: {
|
|
|
- page: 1, // 页码
|
|
|
- size: 99999, // 每页显示条数
|
|
|
- limit: 99999,
|
|
|
- },
|
|
|
- toponym:"",
|
|
|
- map: null,
|
|
|
- feature: null,
|
|
|
- loading: false,
|
|
|
- hand_name: "",
|
|
|
- storeTypeOptions: [],
|
|
|
- supplierOptions: [],
|
|
|
- title: "添加供应商",
|
|
|
- showModelThis: this.showModel,
|
|
|
- ruleForm: {},
|
|
|
- rulesThis: this.rules,
|
|
|
- rules: {
|
|
|
- supplier: [{ required: true, message: "请选择供应商", trigger: "change" }],
|
|
|
- storeName: [{ required: true, message: "请输入门店名称", trigger: "change" }],
|
|
|
- storeType: [{ required: true, message: "请选择门店类型", trigger: "change" }],
|
|
|
- storeImage: [{ required: true, message: "请上传门店主图", trigger: "change" }],
|
|
|
- storeAddr: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: "请选择门店地址",
|
|
|
- trigger: "change",
|
|
|
- validator(rule, value, callback) {
|
|
|
- console.log(value);
|
|
|
- if (
|
|
|
- (!Array.isArray(value) && !value) ||
|
|
|
- (Array.isArray(value) && value.length === 0)
|
|
|
- ) {
|
|
|
- callback(new Error("门店地址不能为空!"));
|
|
|
- } else {
|
|
|
- callback();
|
|
|
- }
|
|
|
- },
|
|
|
- },
|
|
|
- ],
|
|
|
- contactor: [{ required: true, message: "姓名不能为空", trigger: "blur" }],
|
|
|
- mobile: [{ required: true, validator: validatemobile, trigger: "blur" }],
|
|
|
- email: [{ required: true, validator: validEmail, trigger: "blur" }],
|
|
|
- position: [{ required: true, message: "职位不能为空", trigger: "blur" }],
|
|
|
- },
|
|
|
- };
|
|
|
- },
|
|
|
- mounted() {
|
|
|
- // this.initMap();
|
|
|
- // this.registerMapEvent();
|
|
|
- this.initForm();
|
|
|
- },
|
|
|
- methods: {
|
|
|
- initMap() {
|
|
|
- this.map = new Map({
|
|
|
- layers: [
|
|
|
- new TileLayer({
|
|
|
- source: new source.XYZ({
|
|
|
- url:
|
|
|
- "http://t{0-7}.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=" +
|
|
|
- key,
|
|
|
- }),
|
|
|
- }),
|
|
|
- new TileLayer({
|
|
|
- source: new source.XYZ({
|
|
|
- url:
|
|
|
- "http://t3.tianditu.com/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=" + key,
|
|
|
- }),
|
|
|
- }),
|
|
|
- ],
|
|
|
- target: "map",
|
|
|
- view: new View({
|
|
|
- projection: "EPSG:4326",
|
|
|
- center: [115.7, 39.4],
|
|
|
- zoom: 16,
|
|
|
- }),
|
|
|
- });
|
|
|
-
|
|
|
- const iconFeature = new Feature();
|
|
|
- const feature = new Feature({
|
|
|
- geometry: new Point([0, 0]),
|
|
|
- });
|
|
|
-
|
|
|
- feature.setStyle(this.createLabelStyle());
|
|
|
-
|
|
|
- const vectorSource = new source.Vector({
|
|
|
- features: [iconFeature, feature],
|
|
|
- });
|
|
|
- const vectorLayer = new layer.Vector({
|
|
|
- source: vectorSource,
|
|
|
- });
|
|
|
-
|
|
|
- this.feature = feature;
|
|
|
- this.map.addLayer(vectorLayer);
|
|
|
- },
|
|
|
- createLabelStyle() {
|
|
|
- return new style.Style({
|
|
|
- image: new style.Icon({
|
|
|
- anchor: [95, 45],
|
|
|
- scale: 0.2, // 图标缩小显示
|
|
|
- anchorOrigin: "bottom-right", // 标注样式的起点位置
|
|
|
- anchorXUnits: "pixels", // X方向单位:分数
|
|
|
- anchorYUnits: "pixels", // Y方向单位:像素
|
|
|
- offsetOrigin: "bottom-left", // 偏移起点位置的方向
|
|
|
- opacity: 1, // 透明度
|
|
|
- src: "dian.png", //图标的URL
|
|
|
- }),
|
|
|
- text: new style.Text({
|
|
|
- textAlign: "center", //位置
|
|
|
- textBaseline: "middle", //基准线
|
|
|
- font: "normal 14px 微软雅黑", //文字样式
|
|
|
- fill: new style.Fill({
|
|
|
- //文本填充样式(即文字颜色)
|
|
|
- color: "#000",
|
|
|
- }),
|
|
|
- stroke: new style.Stroke({
|
|
|
- color: "#F00",
|
|
|
- width: 2,
|
|
|
- }),
|
|
|
- }),
|
|
|
- });
|
|
|
- },
|
|
|
- registerMapEvent() {
|
|
|
- this.map.on("click", (evt) => {
|
|
|
- const { coordinate } = evt;
|
|
|
- this.ruleForm.storeAddr = [...coordinate];
|
|
|
- this.feature.set("geometry", new Point(coordinate));
|
|
|
- });
|
|
|
- },
|
|
|
- async initForm() {
|
|
|
- this.hand_name = "";
|
|
|
- this.loading = true;
|
|
|
- await this.searchTypeList();
|
|
|
- await this.searchSupplierList();
|
|
|
- this.resetFormData();
|
|
|
- this.rulesThis = this.rules;
|
|
|
- await this.resetForm();
|
|
|
- this.loading = false;
|
|
|
- },
|
|
|
- async resetForm() {
|
|
|
- // 重置
|
|
|
- await this.$nextTick(() => {
|
|
|
- if (this.$refs.ruleForm) {
|
|
|
- this.$refs.ruleForm.resetFields();
|
|
|
- this.$refs.ruleForm.clearValidate();
|
|
|
- this.resetFormData();
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- handleMapSelection({ name, point }){
|
|
|
- this.toponym = name
|
|
|
- },
|
|
|
- resetFormData() {
|
|
|
- this.ruleForm = {
|
|
|
- ...formItem,
|
|
|
- };
|
|
|
- if (this.sitem) {
|
|
|
- const {
|
|
|
- id,
|
|
|
- code,
|
|
|
- supplier,
|
|
|
- storeName,
|
|
|
- type,
|
|
|
- category,
|
|
|
- delivery_way,
|
|
|
- supplier_type,
|
|
|
- level,
|
|
|
- pay_type,
|
|
|
- storeImage,
|
|
|
- prove_img,
|
|
|
- contactor,
|
|
|
- mobile,
|
|
|
- position,
|
|
|
- registercode,
|
|
|
- name,
|
|
|
- nature,
|
|
|
- addr,
|
|
|
- legaler,
|
|
|
- registertime,
|
|
|
- scope,
|
|
|
- personid,
|
|
|
- person,
|
|
|
- telephone,
|
|
|
- email,
|
|
|
- } = this.sitem;
|
|
|
- this.hand_name = person || "";
|
|
|
- }
|
|
|
- },
|
|
|
- closeImg(index) {
|
|
|
- this.ruleForm.prove_img.splice(index, 1);
|
|
|
- this.$refs.ruleForm.validateField("prove_img");
|
|
|
- },
|
|
|
- // 刷新表格
|
|
|
- async searchTypeList() {
|
|
|
- const { code, data } = await asyncRequestStoreType.list(this.parmValue);
|
|
|
- this.storeTypeOptions = code === 1 ? data.list : [];
|
|
|
- },
|
|
|
- // 刷新表格
|
|
|
- async searchSupplierList() {
|
|
|
- const { code, data } = await asyncRequestSupplier.list(this.parmValue);
|
|
|
- this.supplierOptions = code === 1 ? data.list : [];
|
|
|
- },
|
|
|
- async save() {
|
|
|
- console.log(111);
|
|
|
- await this.$refs.ruleForm.validate(async (valid) => {
|
|
|
- console.log(valid);
|
|
|
- if (valid) {
|
|
|
- console.log(this.ruleForm);
|
|
|
- }
|
|
|
- });
|
|
|
- // try {
|
|
|
-
|
|
|
- // await this.$refs.ruleForm.validate();
|
|
|
- // console.log(this.ruleForm);
|
|
|
- // //TODO....
|
|
|
- // } catch (err) {
|
|
|
- // console.log(err);
|
|
|
- // }
|
|
|
- },
|
|
|
- deleteimg() {
|
|
|
- this.ruleForm.storeImage = "";
|
|
|
- this.$refs.ruleForm.validateField("storeImage");
|
|
|
- },
|
|
|
-
|
|
|
- // 图片上传成功
|
|
|
- async UploadSuccessEvent(data) {
|
|
|
- const { url } = data;
|
|
|
- if (url === "noToken") {
|
|
|
- await this.logout();
|
|
|
- } else {
|
|
|
- this.ruleForm.storeImage = url;
|
|
|
- this.$refs.ruleForm.validateField("storeImage");
|
|
|
- this.$message.success("图片上传成功!");
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- // 图片上传失败
|
|
|
- imgUploadError(res) {
|
|
|
- if (res !== "break") {
|
|
|
- this.$message.error("图片上传失败!");
|
|
|
- this.$refs.ruleForm.validateField("storeImage");
|
|
|
- }
|
|
|
- },
|
|
|
- // 判断图片规格
|
|
|
- beforeAvatarUpload(file) {
|
|
|
- let isJPG = false;
|
|
|
- if (
|
|
|
- file.type === "image/jpg" ||
|
|
|
- file.type === "image/png" ||
|
|
|
- file.type === "image/jpeg"
|
|
|
- ) {
|
|
|
- isJPG = true;
|
|
|
- }
|
|
|
- const isLt2M = file.size / 1024 / 1024 < 1;
|
|
|
- if (!isJPG) {
|
|
|
- this.$message.error("图片格式不正确!");
|
|
|
- }
|
|
|
- if (!isLt2M) {
|
|
|
- this.$message.error("图片大小不能超过 1MB!");
|
|
|
- }
|
|
|
- return isJPG && isLt2M;
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
-</script>
|
|
|
-
|
|
|
-<style lang="scss" scoped>
|
|
|
-.supplierAdd {
|
|
|
- .good_info_img_div {
|
|
|
- ul {
|
|
|
- width: 100%;
|
|
|
- li {
|
|
|
- float: left;
|
|
|
- width: 55px;
|
|
|
- height: 55px;
|
|
|
- padding: 0 5px 0 0;
|
|
|
- .img-show-li-div {
|
|
|
- width: 50px;
|
|
|
- height: 50px;
|
|
|
- border: 1px solid #dfe4ed;
|
|
|
- background: #dfe4ed;
|
|
|
- position: relative;
|
|
|
- img.img-show {
|
|
|
- width: 100%;
|
|
|
- height: 100%;
|
|
|
- position: relative;
|
|
|
- display: inline-block;
|
|
|
- }
|
|
|
- i.el-icon-close {
|
|
|
- position: absolute;
|
|
|
- z-index: 2;
|
|
|
- top: 0;
|
|
|
- right: 0;
|
|
|
- color: #dfe4ed;
|
|
|
- }
|
|
|
- &:hover {
|
|
|
- i.el-icon-close {
|
|
|
- cursor: pointer;
|
|
|
- color: #6954f0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- .supplierAdd-title {
|
|
|
- border-left: 5px solid #006eff;
|
|
|
- margin: 6px 0 25px 10px;
|
|
|
- width: 100%;
|
|
|
- box-sizing: border-box;
|
|
|
- padding: 0 0 0 10px;
|
|
|
- }
|
|
|
- .supplierAdd-title-left {
|
|
|
- width: 120px;
|
|
|
- .btnupload {
|
|
|
- width: 40px;
|
|
|
- height: 40px;
|
|
|
- line-height: 40px;
|
|
|
- }
|
|
|
- .avatar-uploader-icon {
|
|
|
- width: 40px;
|
|
|
- height: 40px;
|
|
|
- line-height: 40px;
|
|
|
- }
|
|
|
- .img-find {
|
|
|
- position: relative;
|
|
|
- width: 40px;
|
|
|
- height: 40px;
|
|
|
- line-height: 40px;
|
|
|
- &:hover {
|
|
|
- .img-close {
|
|
|
- color: #409eff;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- .img-close {
|
|
|
- position: absolute;
|
|
|
- top: 0;
|
|
|
- right: 0;
|
|
|
- z-index: 999999;
|
|
|
- &:hover {
|
|
|
- cursor: pointer;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- .supplierAdd-title-right {
|
|
|
- width: calc(100% - 120px);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-#map {
|
|
|
- width: 100%;
|
|
|
- height: 400px;
|
|
|
-
|
|
|
- cursor: pointer;
|
|
|
-}
|
|
|
-</style>
|