|
@@ -1,451 +0,0 @@
|
|
|
-<template>
|
|
|
|
|
- <div>
|
|
|
|
|
- <el-button size="small" type="primary" @click="editBtn">{{
|
|
|
|
|
- $t(`编 辑`)
|
|
|
|
|
- }}</el-button>
|
|
|
|
|
- <el-drawer
|
|
|
|
|
- :title="$t(`编辑营销产品`)"
|
|
|
|
|
- :visible.sync="dialogFormVisible"
|
|
|
|
|
- :wrapperClosable="false"
|
|
|
|
|
- size="60%"
|
|
|
|
|
- direction="rtl"
|
|
|
|
|
- append-to-body
|
|
|
|
|
- :show-close="false"
|
|
|
|
|
- @close="onClose"
|
|
|
|
|
- >
|
|
|
|
|
- <div class="drawer__panel">
|
|
|
|
|
- <el-row :gutter="20">
|
|
|
|
|
- <el-form :model="form" :rules="rules" ref="form" size="mini">
|
|
|
|
|
- <el-col :span="24">
|
|
|
|
|
- <el-form-item :label="$t(`商品`)" prop="itemname">
|
|
|
|
|
- <el-popover
|
|
|
|
|
- placement="bottom-start"
|
|
|
|
|
- width="700"
|
|
|
|
|
- trigger="click"
|
|
|
|
|
- v-model="dialogPopover"
|
|
|
|
|
- >
|
|
|
|
|
- <productTemplate
|
|
|
|
|
- :sa_fadid="form.sa_fadid"
|
|
|
|
|
- @selectPro="selectPro"
|
|
|
|
|
- ></productTemplate>
|
|
|
|
|
- <el-input
|
|
|
|
|
- slot="reference"
|
|
|
|
|
- v-model="form.itemname"
|
|
|
|
|
- :placeholder="$t(`选择商品`)"
|
|
|
|
|
- ></el-input>
|
|
|
|
|
- </el-popover>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- </el-col>
|
|
|
|
|
- <el-col :span="24" v-if="form.langTabs && form.langTabs.length > 0">
|
|
|
|
|
- <el-tabs v-model="activeLang" @tab-click="onLangTabChange" type="card" style="margin-top: 10px;">
|
|
|
|
|
- <el-tab-pane
|
|
|
|
|
- v-for="tab in form.langTabs"
|
|
|
|
|
- :key="tab.languagecode"
|
|
|
|
|
- :label="tab.languagename"
|
|
|
|
|
- :name="tab.languagecode"
|
|
|
|
|
- ></el-tab-pane>
|
|
|
|
|
- </el-tabs>
|
|
|
|
|
- </el-col>
|
|
|
|
|
- <el-col :span="24">
|
|
|
|
|
- <el-form-item>
|
|
|
|
|
- <p style="font-size: 14px; margin-top: 10px">
|
|
|
|
|
- {{ $t("技术参数") }}
|
|
|
|
|
- </p>
|
|
|
|
|
- <div style="margin-top: 10px; min-height: 200px !important">
|
|
|
|
|
- <myEditor
|
|
|
|
|
- ref="technicalparam"
|
|
|
|
|
- height="360px"
|
|
|
|
|
- :content="form.technicalparam"
|
|
|
|
|
- :id="form.sa_fadid"
|
|
|
|
|
- ></myEditor>
|
|
|
|
|
- </div>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- </el-col>
|
|
|
|
|
- <el-col :span="24">
|
|
|
|
|
- <el-form-item>
|
|
|
|
|
- <p style="font-size: 14px; margin-top: 10px">
|
|
|
|
|
- {{ $t("材质说明") }}
|
|
|
|
|
- </p>
|
|
|
|
|
- <div style="margin-top: 10px; min-height: 200px !important">
|
|
|
|
|
- <myEditor
|
|
|
|
|
- ref="materialdescription"
|
|
|
|
|
- height="360px"
|
|
|
|
|
- :content="form.materialdescription"
|
|
|
|
|
- :id="form.sa_fadid"
|
|
|
|
|
- ></myEditor>
|
|
|
|
|
- </div>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- </el-col>
|
|
|
|
|
- <el-col :span="24">
|
|
|
|
|
- <el-form-item>
|
|
|
|
|
- <p style="font-size: 14px; margin-top: 10px">
|
|
|
|
|
- {{ $t("产品概述") }}
|
|
|
|
|
- </p>
|
|
|
|
|
- <div style="margin-top: 10px; min-height: 200px !important">
|
|
|
|
|
- <myEditor
|
|
|
|
|
- ref="content"
|
|
|
|
|
- height="360px"
|
|
|
|
|
- :content="form.content"
|
|
|
|
|
- :id="form.sa_fadid"
|
|
|
|
|
- ></myEditor>
|
|
|
|
|
- </div>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- </el-col>
|
|
|
|
|
- <el-col :span="24">
|
|
|
|
|
- <el-form-item :label="$t('分类')" prop="classmx">
|
|
|
|
|
- <el-cascader
|
|
|
|
|
- ref="selectdep"
|
|
|
|
|
- size="small"
|
|
|
|
|
- style="width: 100%"
|
|
|
|
|
- :placeholder="$t(form.class || '分类')"
|
|
|
|
|
- v-model="form.classmx"
|
|
|
|
|
- :options="classData"
|
|
|
|
|
- filterable
|
|
|
|
|
- :props="{
|
|
|
|
|
- emitPath: false,
|
|
|
|
|
- expandTrigger: 'hover',
|
|
|
|
|
- checkStrictly: false,
|
|
|
|
|
- label: 'remarks',
|
|
|
|
|
- value: 'value',
|
|
|
|
|
- children: 'subvalues',
|
|
|
|
|
- }"
|
|
|
|
|
- clearable
|
|
|
|
|
- ></el-cascader>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- </el-col>
|
|
|
|
|
- <el-col :span="24">
|
|
|
|
|
- <div class="upload-box">
|
|
|
|
|
- <div class="label" style="margin-top: 3px">
|
|
|
|
|
- {{ $t("产品资料") }}
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <upload
|
|
|
|
|
- :classType="['image', 'video', 'document', 'pdf']"
|
|
|
|
|
- @oploadIng="oploadIng"
|
|
|
|
|
- ref="upload"
|
|
|
|
|
- >
|
|
|
|
|
- <div style="width: 400px; text-align: left">
|
|
|
|
|
- <el-button size="small" type="primary">
|
|
|
|
|
- <span
|
|
|
|
|
- class="icon iconfont"
|
|
|
|
|
- style="margin-right: 5px; font-size: 14px"
|
|
|
|
|
- ></span
|
|
|
|
|
- >
|
|
|
|
|
- {{ $t("点击上传") }}
|
|
|
|
|
- </el-button>
|
|
|
|
|
- </div>
|
|
|
|
|
- </upload>
|
|
|
|
|
- </div>
|
|
|
|
|
- </el-col>
|
|
|
|
|
- <el-col :span="24">
|
|
|
|
|
- <el-form-item :label="$t('状态')" prop="status">
|
|
|
|
|
- <el-radio-group v-model="form.isonsale" style="width: 100%">
|
|
|
|
|
- <el-radio label="0">{{ $t("新建") }}</el-radio>
|
|
|
|
|
- <el-radio label="1">{{ $t(`发布`) }}</el-radio>
|
|
|
|
|
- </el-radio-group>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- </el-col>
|
|
|
|
|
- </el-form>
|
|
|
|
|
- </el-row>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div class="fixed__btn__panel">
|
|
|
|
|
- <el-button
|
|
|
|
|
- size="small"
|
|
|
|
|
- @click="onClose"
|
|
|
|
|
- plain
|
|
|
|
|
- class="normal-btn-width"
|
|
|
|
|
- :disabled="loading || disabled"
|
|
|
|
|
- >{{ $t(`取 消`) }}</el-button
|
|
|
|
|
- >
|
|
|
|
|
- <el-button
|
|
|
|
|
- size="small"
|
|
|
|
|
- type="primary"
|
|
|
|
|
- @click="onSubmit"
|
|
|
|
|
- class="normal-btn-width"
|
|
|
|
|
- :disabled="disabled"
|
|
|
|
|
- :loading="loading"
|
|
|
|
|
- >{{ $t(`确 定`) }}</el-button
|
|
|
|
|
- >
|
|
|
|
|
- </div>
|
|
|
|
|
- </el-drawer>
|
|
|
|
|
- </div>
|
|
|
|
|
-</template>
|
|
|
|
|
-
|
|
|
|
|
-<script>
|
|
|
|
|
-import productTemplate from "@/WebsiteManagement/marketproductMag/compents/productTemplate";
|
|
|
|
|
-import myEditor from "@/components/my-editor/Editor.vue";
|
|
|
|
|
-import upload from "../compents/upload";
|
|
|
|
|
-
|
|
|
|
|
-export default {
|
|
|
|
|
- name: "edit",
|
|
|
|
|
- components: { productTemplate, myEditor, upload },
|
|
|
|
|
- props: ["data"],
|
|
|
|
|
- data() {
|
|
|
|
|
- return {
|
|
|
|
|
- dialogFormVisible: false,
|
|
|
|
|
- dialogPopover: false,
|
|
|
|
|
- loading: false,
|
|
|
|
|
- disabled: false,
|
|
|
|
|
- classData: [],
|
|
|
|
|
- activeLang: '',
|
|
|
|
|
- previousLang: '',
|
|
|
|
|
- translations: {
|
|
|
|
|
- technicalparam: {},
|
|
|
|
|
- materialdescription: {},
|
|
|
|
|
- content: {},
|
|
|
|
|
- },
|
|
|
|
|
- form: {
|
|
|
|
|
- siteid: JSON.parse(sessionStorage.getItem("active_account")).siteid,
|
|
|
|
|
- sa_fadid: 0, //sa_brandid<=0时 为新增
|
|
|
|
|
- itemid: "",
|
|
|
|
|
- itemname: "",
|
|
|
|
|
- itemno: "",
|
|
|
|
|
- class: "",
|
|
|
|
|
- materialdescription: "",
|
|
|
|
|
- technicalparam: "",
|
|
|
|
|
- isonsale: "1",
|
|
|
|
|
- classmx: "",
|
|
|
|
|
- langTabs: [],
|
|
|
|
|
- },
|
|
|
|
|
- rules: {
|
|
|
|
|
- itemname: [
|
|
|
|
|
- { required: true, message: this.$t("请选择商品"), trigger: "change" },
|
|
|
|
|
- ],
|
|
|
|
|
- classmx: [
|
|
|
|
|
- { required: true, message: this.$t("请选择分类"), trigger: "change" },
|
|
|
|
|
- ],
|
|
|
|
|
- },
|
|
|
|
|
- };
|
|
|
|
|
- },
|
|
|
|
|
- updated() {
|
|
|
|
|
- if (this.$refs.technicalparam)
|
|
|
|
|
- this.$refs.technicalparam.innerHTML = this.form.technicalparam;
|
|
|
|
|
- if (this.$refs.materialdescription)
|
|
|
|
|
- this.$refs.materialdescription.innerHTML = this.form.materialdescription;
|
|
|
|
|
- if (this.$refs.content)
|
|
|
|
|
- this.$refs.content.innerHTML = this.form.content;
|
|
|
|
|
- try {
|
|
|
|
|
- if (!this.$refs.upload.filelist.length)
|
|
|
|
|
- this.$refs.upload.filelist = this.fileType
|
|
|
|
|
- .fileList(this.data.attinfos)
|
|
|
|
|
- .map((v) => {
|
|
|
|
|
- v.progress = 100;
|
|
|
|
|
- v.type = v.postfix;
|
|
|
|
|
- v.uid = v.attachmentid;
|
|
|
|
|
- return v;
|
|
|
|
|
- });
|
|
|
|
|
- } catch (error) {}
|
|
|
|
|
- },
|
|
|
|
|
- methods: {
|
|
|
|
|
- oploadIng(e) {
|
|
|
|
|
- this.disabled = e;
|
|
|
|
|
- },
|
|
|
|
|
- async editBtn() {
|
|
|
|
|
- this.queryClass();
|
|
|
|
|
- const langRes = await this.$api.requested({ id: 10026401 });
|
|
|
|
|
- const res = await this.$api.requested({
|
|
|
|
|
- id: "20240920101403",
|
|
|
|
|
- content: {
|
|
|
|
|
- siteid: JSON.parse(sessionStorage.getItem("active_account")).siteid,
|
|
|
|
|
- sa_fadid: this.data.sa_fadid,
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
- if (res.code == 0) {
|
|
|
|
|
- this.tool.showMessage(res, () => {});
|
|
|
|
|
- } else {
|
|
|
|
|
- this.dialogFormVisible = true;
|
|
|
|
|
- this.form = res.data;
|
|
|
|
|
- this.form.isonsale = res.data.isonsale == 1 ? "1" : "0";
|
|
|
|
|
- this.form.langTabs = langRes.data || [];
|
|
|
|
|
- this.initTranslations();
|
|
|
|
|
- if (this.form.langTabs.length > 0) {
|
|
|
|
|
- this.activeLang = this.form.langTabs[0].languagecode;
|
|
|
|
|
- this.previousLang = this.form.langTabs[0].languagecode;
|
|
|
|
|
- }
|
|
|
|
|
- await this.queryTranslations(this.form.sa_fadid);
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- onSubmit() {
|
|
|
|
|
- this.$refs.form.validate(async (valid) => {
|
|
|
|
|
- if (!valid) return false;
|
|
|
|
|
- this.loading = true;
|
|
|
|
|
- this.saveCurrentTranslations(this.activeLang);
|
|
|
|
|
- const defaultLang = this.form.langTabs[0]?.languagecode || '';
|
|
|
|
|
- this.form.technicalparam = this.translations.technicalparam[defaultLang] || '';
|
|
|
|
|
- this.form.materialdescription = this.translations.materialdescription[defaultLang] || '';
|
|
|
|
|
- this.form.content = this.translations.content[defaultLang] || '';
|
|
|
|
|
- const selectdep = this.$refs.selectdep._data.inputValue.split(" / ");
|
|
|
|
|
- this.form.class = selectdep[0] || "";
|
|
|
|
|
- this.form.classmx = selectdep[1] || "";
|
|
|
|
|
- const res = await this.$api.requested({
|
|
|
|
|
- id: "20240920101303",
|
|
|
|
|
- content: this.form,
|
|
|
|
|
- });
|
|
|
|
|
- await this.$refs.upload.rebinding("sa_fad", res.data.sa_fadid);
|
|
|
|
|
- this.$refs.upload.linksids.length
|
|
|
|
|
- ? await this.$refs.upload.deleteAllTemporaryFiles(
|
|
|
|
|
- this.$refs.upload.linksids
|
|
|
|
|
- )
|
|
|
|
|
- : "";
|
|
|
|
|
- this.tool.showMessage(res, async () => {
|
|
|
|
|
- const res1 = await this.$api.requested({
|
|
|
|
|
- id: "20240920101603",
|
|
|
|
|
- content: {
|
|
|
|
|
- siteid: this.form.siteid,
|
|
|
|
|
- sa_fadids: [res.data.sa_fadid],
|
|
|
|
|
- isonsale: this.form.isonsale,
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
- this.dialogFormVisible = false;
|
|
|
|
|
- this.onClose();
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- selectPro(data) {
|
|
|
|
|
- this.dialogPopover = false;
|
|
|
|
|
- this.form.itemname = data.itemname;
|
|
|
|
|
- this.form.itemid = data.itemid;
|
|
|
|
|
- this.form.itemno = data.itemno;
|
|
|
|
|
- },
|
|
|
|
|
- initTranslations() {
|
|
|
|
|
- const fields = ['technicalparam', 'materialdescription', 'content']
|
|
|
|
|
- fields.forEach(field => {
|
|
|
|
|
- this.translations[field] = {}
|
|
|
|
|
- this.form.langTabs.forEach(tab => {
|
|
|
|
|
- this.translations[field][tab.languagecode] = ''
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- saveCurrentTranslations(lang) {
|
|
|
|
|
- const fields = ['technicalparam', 'materialdescription', 'content']
|
|
|
|
|
- const refs = this.$refs
|
|
|
|
|
- fields.forEach(field => {
|
|
|
|
|
- if (refs[field] && refs[field].editor) {
|
|
|
|
|
- this.translations[field][lang] = refs[field].editor.getHtml()
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- loadCurrentTranslations() {
|
|
|
|
|
- const fields = ['technicalparam', 'materialdescription', 'content']
|
|
|
|
|
- const refs = this.$refs
|
|
|
|
|
- this.$nextTick(() => {
|
|
|
|
|
- fields.forEach(field => {
|
|
|
|
|
- const comp = refs[field]
|
|
|
|
|
- if (comp && comp.editor) {
|
|
|
|
|
- const html = this.translations[field][this.activeLang] || ''
|
|
|
|
|
- comp.html = html
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- async onLangTabChange(tab) {
|
|
|
|
|
- this.saveCurrentTranslations(this.previousLang)
|
|
|
|
|
- this.previousLang = tab.name
|
|
|
|
|
- const defaultLang = this.form.langTabs[0]?.languagecode || ''
|
|
|
|
|
- if (tab.name !== defaultLang) {
|
|
|
|
|
- await this.queryTranslationsByLang(this.form.sa_fadid, tab.name)
|
|
|
|
|
- }
|
|
|
|
|
- this.loadCurrentTranslations()
|
|
|
|
|
- },
|
|
|
|
|
- async queryTranslationsByLang(ownerid, lang) {
|
|
|
|
|
- const fields = ['technicalparam', 'materialdescription', 'content']
|
|
|
|
|
- for (const field of fields) {
|
|
|
|
|
- try {
|
|
|
|
|
- const res = await this.$api.requested({
|
|
|
|
|
- id: 10027101,
|
|
|
|
|
- content: {
|
|
|
|
|
- ownertable: 'sa_fad',
|
|
|
|
|
- ownerid: ownerid,
|
|
|
|
|
- languagecode: lang,
|
|
|
|
|
- columnname: field,
|
|
|
|
|
- },
|
|
|
|
|
- })
|
|
|
|
|
- if (res.data && res.data.value_translate !== undefined) {
|
|
|
|
|
- this.translations[field][lang] = res.data.value_translate
|
|
|
|
|
- } else if (res.data && typeof res.data === 'string') {
|
|
|
|
|
- this.translations[field][lang] = res.data
|
|
|
|
|
- }
|
|
|
|
|
- } catch (e) {}
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- async queryTranslations(ownerid) {
|
|
|
|
|
- const fields = ['technicalparam', 'materialdescription', 'content']
|
|
|
|
|
- const defaultLang = this.form.langTabs[0]?.languagecode || ''
|
|
|
|
|
- for (const field of fields) {
|
|
|
|
|
- for (const tab of this.form.langTabs) {
|
|
|
|
|
- if (tab.languagecode === defaultLang) continue
|
|
|
|
|
- try {
|
|
|
|
|
- const res = await this.$api.requested({
|
|
|
|
|
- id: 10027101,
|
|
|
|
|
- content: {
|
|
|
|
|
- ownertable: 'sa_fad',
|
|
|
|
|
- ownerid: ownerid,
|
|
|
|
|
- languagecode: tab.languagecode,
|
|
|
|
|
- columnname: field,
|
|
|
|
|
- },
|
|
|
|
|
- })
|
|
|
|
|
- if (res.data && res.data.value_translate !== undefined) {
|
|
|
|
|
- this.translations[field][tab.languagecode] = res.data.value_translate
|
|
|
|
|
- } else if (res.data && typeof res.data === 'string') {
|
|
|
|
|
- this.translations[field][tab.languagecode] = res.data
|
|
|
|
|
- }
|
|
|
|
|
- } catch (e) {}
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- async queryClass() {
|
|
|
|
|
- const res = await this.$store.dispatch(
|
|
|
|
|
- "optiontypeselect",
|
|
|
|
|
- "marketproductclass"
|
|
|
|
|
- );
|
|
|
|
|
- this.classData = [];
|
|
|
|
|
- this.classData = res.data.map((item) => {
|
|
|
|
|
- let data = {
|
|
|
|
|
- value: item.value,
|
|
|
|
|
- remarks: item.remarks,
|
|
|
|
|
- };
|
|
|
|
|
- if (item.subvalues.length)
|
|
|
|
|
- data.subvalues = item.subvalues.map((k) => {
|
|
|
|
|
- return {
|
|
|
|
|
- value: k,
|
|
|
|
|
- remarks: k,
|
|
|
|
|
- };
|
|
|
|
|
- });
|
|
|
|
|
- return data;
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- onClose() {
|
|
|
|
|
- this.loading = false;
|
|
|
|
|
- this.dialogFormVisible = false;
|
|
|
|
|
- this.$refs.form.resetFields();
|
|
|
|
|
- this.$refs.technicalparam.html = this.form.technicalparam;
|
|
|
|
|
- this.$refs.materialdescription.html = this.form.materialdescription;
|
|
|
|
|
- this.$refs.content.html = this.form.content;
|
|
|
|
|
- this.activeLang = '';
|
|
|
|
|
- this.previousLang = '';
|
|
|
|
|
- this.translations = {
|
|
|
|
|
- technicalparam: {},
|
|
|
|
|
- materialdescription: {},
|
|
|
|
|
- content: {},
|
|
|
|
|
- };
|
|
|
|
|
- this.$emit("onSuccess");
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- mounted() {},
|
|
|
|
|
-};
|
|
|
|
|
-</script>
|
|
|
|
|
-
|
|
|
|
|
-<style scoped>
|
|
|
|
|
-.upload-box {
|
|
|
|
|
- width: 100%;
|
|
|
|
|
- display: flex;
|
|
|
|
|
- padding: 10px 0 13px;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-.upload-box .label {
|
|
|
|
|
- font-size: 14px;
|
|
|
|
|
- margin-right: 20px;
|
|
|
|
|
- margin-top: 3px;
|
|
|
|
|
- color: #606266;
|
|
|
|
|
-}
|
|
|
|
|
-</style>
|
|
|