Browse Source

提货点增加经纬度;商品详情增加编辑内容

master
liupopo 2 years ago
parent
commit
c2e21e78d8
  1. 3
      package.json
  2. 279
      src/components/Editor/index.vue
  3. 27
      src/views/commodity/commodityAdd.vue
  4. 10
      src/views/pickupPoint/indexAdd.vue

3
package.json

@ -14,10 +14,10 @@
"test:ci": "npm run lint && npm run test:unit"
},
"dependencies": {
"echarts": "^5.4.3",
"axios": "^0.24.0",
"bpmn-js": "^9.2.2",
"core-js": "^3.8.3",
"echarts": "^5.4.3",
"ejs": "^2.7.4",
"element-ui": "^2.15.14",
"js-cookie": "2.2.0",
@ -27,6 +27,7 @@
"path-to-regexp": "2.4.0",
"portfinder": "^1.0.21",
"qs": "^6.9.4",
"quill": "^1.3.7",
"sass-resources-loader": "^2.1.1",
"viewerjs": "^1.9.0",
"vue": "^2.6.14",

279
src/components/Editor/index.vue

@ -0,0 +1,279 @@
<template>
<div>
<el-upload
:action="uploadUrl"
:before-upload="handleBeforeUpload"
:on-success="handleUploadSuccess"
:on-error="handleUploadError"
name="file"
:show-file-list="false"
:headers="headers"
style="display: none"
ref="upload"
v-if="this.type == 'url'"
>
</el-upload>
<div class="editor" ref="editor" :style="styles"></div>
</div>
</template>
<script>
import Quill from "quill";
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
import { getToken } from "@/utils/auth";
export default {
name: "Editor",
props: {
/* 编辑器的内容 */
value: {
type: String,
default: "",
},
/* 高度 */
height: {
type: Number,
default: null,
},
/* 最小高度 */
minHeight: {
type: Number,
default: null,
},
/* 只读 */
readOnly: {
type: Boolean,
default: false,
},
// (MB)
fileSize: {
type: Number,
default: 5,
},
/* 类型(base64格式、url格式) */
type: {
type: String,
default: "url",
}
},
data() {
return {
uploadUrl: process.env.VUE_APP_BASE_API + "/file/upload", //
headers: {
Authorization: "Bearer " + getToken()
},
Quill: null,
currentValue: "",
options: {
theme: "snow",
bounds: document.body,
debug: "warn",
modules: {
//
toolbar: [
["bold", "italic", "underline", "strike"], // 线 线
["blockquote", "code-block"], //
[{ list: "ordered" }, { list: "bullet" }], //
[{ indent: "-1" }, { indent: "+1" }], //
[{ size: ["small", false, "large", "huge"] }], //
[{ header: [1, 2, 3, 4, 5, 6, false] }], //
[{ color: [] }, { background: [] }], //
[{ align: [] }], //
["clean"], //
["link", "image", "video"] //
],
},
placeholder: "请输入内容",
readOnly: this.readOnly,
},
};
},
computed: {
styles() {
let style = {};
if (this.minHeight) {
style.minHeight = `${this.minHeight}px`;
}
if (this.height) {
style.height = `${this.height}px`;
}
return style;
},
},
watch: {
value: {
handler(val) {
if (val !== this.currentValue) {
this.currentValue = val === null ? "" : val;
if (this.Quill) {
this.Quill.pasteHTML(this.currentValue);
}
}
},
immediate: true,
},
},
mounted() {
this.init();
},
beforeDestroy() {
this.Quill = null;
},
methods: {
init() {
const editor = this.$refs.editor;
this.Quill = new Quill(editor, this.options);
//
if (this.type == 'url') {
let toolbar = this.Quill.getModule("toolbar");
toolbar.addHandler("image", (value) => {
this.uploadType = "image";
if (value) {
this.$refs.upload.$children[0].$refs.input.click();
} else {
this.quill.format("image", false);
}
});
}
this.Quill.pasteHTML(this.currentValue);
this.Quill.on("text-change", (delta, oldDelta, source) => {
const html = this.$refs.editor.children[0].innerHTML;
const text = this.Quill.getText();
const quill = this.Quill;
this.currentValue = html;
this.$emit("input", html);
this.$emit("on-change", { html, text, quill });
});
this.Quill.on("text-change", (delta, oldDelta, source) => {
this.$emit("on-text-change", delta, oldDelta, source);
});
this.Quill.on("selection-change", (range, oldRange, source) => {
this.$emit("on-selection-change", range, oldRange, source);
});
this.Quill.on("editor-change", (eventName, ...args) => {
this.$emit("on-editor-change", eventName, ...args);
});
},
//
handleBeforeUpload(file) {
//
if (this.fileSize) {
const isLt = file.size / 1024 / 1024 < this.fileSize;
if (!isLt) {
this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`);
return false;
}
}
return true;
},
handleUploadSuccess(res, file) {
//
let quill = this.Quill;
//
// if (res.code == 200) {
// //
// let length = quill.getSelection().index;
// // res.url
// quill.insertEmbed(length, "image", process.env.VUE_APP_BASE_API + res.fileName);
// //
// quill.setSelection(length + 1);
if (res.code == "200") {
//
let length = quill.getSelection().index;
// res.url
quill.insertEmbed(length, "image", res.data.fullUrl);
//
quill.setSelection(length + 1);
} else {
this.$message.error("图片插入失败");
}
},
handleUploadError() {
this.$message.error("图片插入失败");
},
},
};
</script>
<style>
.editor, .ql-toolbar {
white-space: pre-wrap !important;
line-height: normal !important;
}
.quill-img {
display: none;
}
.ql-snow .ql-tooltip[data-mode="link"]::before {
content: "请输入链接地址:";
}
.ql-snow .ql-tooltip.ql-editing a.ql-action::after {
border-right: 0px;
content: "保存";
padding-right: 0px;
}
.ql-snow .ql-tooltip[data-mode="video"]::before {
content: "请输入视频地址:";
}
.ql-snow .ql-picker.ql-size .ql-picker-label::before,
.ql-snow .ql-picker.ql-size .ql-picker-item::before {
content: "14px";
}
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="small"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="small"]::before {
content: "10px";
}
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="large"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="large"]::before {
content: "18px";
}
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="huge"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="huge"]::before {
content: "32px";
}
.ql-snow .ql-picker.ql-header .ql-picker-label::before,
.ql-snow .ql-picker.ql-header .ql-picker-item::before {
content: "文本";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="1"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="1"]::before {
content: "标题1";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before {
content: "标题2";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before {
content: "标题3";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="4"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="4"]::before {
content: "标题4";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="5"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="5"]::before {
content: "标题5";
}
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="6"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="6"]::before {
content: "标题6";
}
.ql-snow .ql-picker.ql-font .ql-picker-label::before,
.ql-snow .ql-picker.ql-font .ql-picker-item::before {
content: "标准字体";
}
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="serif"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="serif"]::before {
content: "衬线字体";
}
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="monospace"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="monospace"]::before {
content: "等宽字体";
}
</style>

27
src/views/commodity/commodityAdd.vue

@ -22,13 +22,11 @@
</div>
<div class="item">
<span class="item_text">编码</span>
<el-input v-model="formobj.code" placeholder="" class="item_input" clearable
oninput="value=value.replace(/[^A-Za-z0-9]/g, '')" />
<el-input v-model="formobj.code" placeholder="" class="item_input" clearable oninput="value=value.replace(/[^A-Za-z0-9]/g, '')" />
</div>
<div class="item">
<span class="item_text">条码</span>
<el-input v-model="formobj.barcode" placeholder="" class="item_input" clearable
oninput="value=value.replace(/[^0-9]/g,'')" />
<el-input v-model="formobj.barcode" placeholder="" class="item_input" clearable oninput="value=value.replace(/[^0-9]/g,'')" />
</div>
<div class="item">
<span class="item_text">价格</span>
@ -44,10 +42,9 @@
<el-input v-model="formobj.remarks" placeholder="例如:一份30斤" class="item_input" clearable />
</div>
<div class="item" style="margin-bottom: 100px;margin-top: 100px;">
<span class="item_text">图片</span>
<upload style="margin-top: 20px;" class="item_input" ref="uploadImg2" v-model="imgList" :limit="1"
@change="backData" bucket="map" :upload-data="{ type: '0001' }"></upload>
<div>
<span class="item_text">商品详情</span>
<editor :height="300" :minHeight="100" :value="formobj.appContent" @input="editinput"></editor>
</div>
</el-card>
@ -60,10 +57,12 @@
<script>
import req from '@/api/commodity/commodity.js'
import upload from '@/components/uploadFile/upload_yanchejianchaTuBiao.vue'
import Editor from '@/components/Editor'
export default {
components: {
upload
upload,
Editor
},
data() {
return {
@ -79,8 +78,9 @@
barcode: '',
price: "",
unitName: "",
remarks:"",
picUrl: ""
remarks: "",
picUrl: "",
appContent:''
}
}
},
@ -120,7 +120,7 @@
barcode: '',
price: "",
unitName: "",
remarks:"",
remarks: "",
picUrl: ""
}
this.$emit('doback')
@ -148,6 +148,9 @@
url: formobj.picUrl
})
})
},
editinput(text) {
this.formobj.appContent = text
}
}
}

10
src/views/pickupPoint/indexAdd.vue

@ -40,6 +40,10 @@
<span class="item_text">排序</span>
<el-input v-model="formobj.sort" placeholder="" class="item_input" clearable />
</div>
<div class="item">
<span class="item_text">经纬度</span>
<el-input v-model="formobj.lonAndLat" placeholder="经纬度,以逗号分隔" class="item_input" clearable />
</div>
</el-card>
@ -63,7 +67,8 @@
businessHours: '',
sort: 0,
linker: '',
picUrl: ''
picUrl: '',
lonAndLat: ''
}
}
},
@ -97,7 +102,8 @@
businessHours: '',
sort: 0,
linker: '',
picUrl: ''
picUrl: '',
lonAndLat: ''
}
this.$emit('doback')
},

Loading…
Cancel
Save