123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910 |
- <template>
- <el-dialog
- v-loading="loading"
- :title="title"
- :center="true"
- align="left"
- top="8vh"
- width="1040px"
- :close-on-click-modal="false"
- :visible.sync="showModelThis"
- element-loading-text="拼命加载中"
- element-loading-spinner="el-icon-loading"
- element-loading-background="rgba(0, 0, 0, 0.8)"
- @close="showModelThis = false"
- append-to-body
- >
- <el-card style="margin: -20px 0 0 0">
- <el-row :gutter="10">
- <el-col :span="24">
- <el-form
- ref="ruleForm"
- :model="ruleForm"
- status-icon
- :size="'mini'"
- :rules="rulesThis"
- label-width="90px"
- class="demo-ruleForm"
- >
- <el-row>
- <el-col :span="8">
- <el-form-item label="到货日期" prop="arrival_time">
- <el-date-picker
- v-model="ruleForm.arrival_time"
- type="date"
- style="width: 100%"
- :disabled="ruleForm.p_arrtime"
- value-format="yyyy-MM-dd"
- :picker-options="pickerOptions"
- placeholder="到货日期"
- >
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="是否多地" prop="is_addrs">
- <el-select
- v-model="ruleForm.is_addrs"
- placeholder="是否多地"
- style="width: 100%"
- >
- <el-option
- v-for="item in is_addrs_options"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="预算单价" prop="budget_price">
- <digital-input
- :values="ruleForm.budget_price"
- :placeholder="'预算单价'"
- :min="0"
- :max="100000000000"
- :position="'right'"
- :precision="2"
- :size="'mini'"
- :disabled="ruleForm.p_budget_price"
- :controls="false"
- :append="'元'"
- @reschange="num_change($event, 'budget_price')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="4">
- <el-form-item label="数量" prop="num" label-width="60px">
- <digital-input
- :values="ruleForm.num"
- :placeholder="'数量'"
- :min="0"
- :max="100000000000"
- :position="'right'"
- :precision="0"
- :size="'mini'"
- :disabled="ruleForm.p_num"
- :controls="false"
- :append="''"
- @reschange="num_change($event, 'num')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="品牌" prop="brand_id">
- <search-brand
- :value="ruleForm.brand_id"
- :size="'mini'"
- :isDetail="listindex !== '-1'"
- :names="ruleForm.brand_name"
- :placeholder="'品牌'"
- @searchChange="brand_id_searchChange"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="是否定制" prop="is_custom">
- <el-select
- v-model="ruleForm.is_custom"
- placeholder="是否定制"
- style="width: 100%"
- >
- <el-option
- v-for="item in is_custom_options"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="重量" prop="total_weight">
- <digital-input
- :values="ruleForm.total_weight"
- :placeholder="'重量'"
- :min="0"
- :max="100000000000"
- :position="'right'"
- :precision="3"
- :controls="false"
- :size="'mini'"
- :append="'g'"
- @reschange="num_change($event, 'total_weight')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="4">
- <el-form-item label="单位" prop="unit" label-width="60px">
- <search-unit
- :value="ruleForm.unit"
- :size="'mini'"
- :isDetail="listindex !== '-1'"
- :names="ruleForm.unit_name"
- :placeholder="'单位'"
- @searchChange="unitsearchChange"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="商品分类" prop="cat_id">
- <search-sort
- :value="ruleForm.cat_id"
- :placeholder="'商品分类'"
- :disabled="false"
- :size="'mini'"
- :names="ruleForm.cat_id_name"
- :isDetail="listindex !== '-1'"
- @searchChange="goods_class_change"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="商品名称" prop="good_name">
- <el-input
- v-model="ruleForm.good_name"
- :disabled="false"
- placeholder="商品名称"
- maxlength="100"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="工艺说明" prop="cost_desc">
- <el-input
- v-model="ruleForm.cost_desc"
- placeholder="工艺说明"
- maxlength="500"
- />
- </el-form-item>
- <el-form-item label="产品用途" prop="use_desc">
- <el-input
- v-model="ruleForm.use_desc"
- placeholder="产品用途"
- maxlength="500"
- />
- </el-form-item>
- <el-form-item label="商品备注" prop="remark">
- <el-input
- v-model="ruleForm.remark"
- placeholder="商品备注"
- maxlength="500"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12" style="padding: 0 0 0 15px">
- <el-table
- :data="spec_tableData"
- :size="'mini'"
- border
- style="width: 100%"
- height="120px"
- >
- <el-table-column prop="spec_name" label="规格类型" />
- <el-table-column prop="spec_value_name" label="规格值" />
- <el-table-column fixed="right" width="88px">
- <template slot="header" slot-scope="scope">
- <span>操作</span>
- <el-tooltip
- class="item"
- effect="dark"
- content="添加规格类型"
- placement="top"
- >
- <i
- class="el-icon-circle-plus-outline fr"
- style="font-size: 18px; margin-top: 2px"
- @click="openEdit('-1', {})"
- />
- </el-tooltip>
- </template>
- <template slot-scope="scope">
- <el-tooltip effect="dark" content="修改" placement="top">
- <i
- class="el-icon-edit tb-icon"
- @click="openEdit(scope.$index, scope.row)"
- ></i>
- </el-tooltip>
- <el-tooltip effect="dark" content="删除" placement="top">
- <i
- class="el-icon-delete tb-icon"
- @click="openDelete(scope.$index)"
- ></i>
- </el-tooltip>
- </template>
- </el-table-column>
- </el-table>
- <!-- 弹窗 新增/修改 -->
- <base-form-add-edit
- :index="modelIndex"
- :show-model="showOtherModel"
- :sitem="modelSitem"
- @refresh="refreshEdit"
- @cancel="showOtherModel = false"
- />
- </el-col>
- <el-col :span="24">
- <el-row>
- <el-col :span="12" v-if="is_noble">
- <el-form-item label="配置要求" prop="config">
- <el-select
- v-model="ruleForm.config"
- multiple
- style="width: 100%"
- placeholder="配置要求"
- >
- <el-option
- v-for="(item, index) in config_options"
- :key="item + index"
- :label="item"
- :value="item"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6" v-if="is_noble">
- <el-form-item label="金属克重" prop="specs_weight">
- <digital-input
- :values="ruleForm.specs_weight"
- :placeholder="'金属克重'"
- :min="0"
- :max="100000000000"
- :position="'right'"
- :precision="3"
- :controls="false"
- :size="'mini'"
- :append="'g'"
- @reschange="num_change($event, 'specs_weight')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6" v-if="is_noble">
- <el-form-item label="启用金价" prop="is_gold_price">
- <el-select
- v-model="ruleForm.is_gold_price"
- placeholder="启用金价"
- style="width: 100%"
- >
- <el-option
- v-for="item in is_gold_price_options"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- </el-col>
- <el-col :span="24" style="text-align: right">
- <el-row>
- <el-col :span="8" class="clear">
- <el-form-item
- label="商品图片"
- prop="good_img"
- class="activity-upload"
- >
- <div class="btnupload" style="position: relative">
- <img
- v-if="ruleForm.good_img"
- :src="ruleForm.good_img"
- class="avatar"
- />
- <i v-else class="el-icon-plus avatar-uploader-icon"></i>
- <file-upload
- class="Upload"
- :disabled="false"
- :accept="'.jpg,.png,.jpeg'"
- :multiple="true"
- :uploadcondition="beforeAvatarUpload"
- @UploadErrorEvent="UploadErrorEvent"
- @UploadSuccessEvent="UploadSuccessEvent"
- ></file-upload>
- </div>
- <div class="txt-tips fl">
- <p>小于1Mb</p>
- </div>
- </el-form-item>
- </el-col>
- <el-col :span="8" class="clear">
- <el-form-item
- label="附件"
- prop="enclosure_file"
- class="activity-upload"
- >
- <div
- v-if="ruleForm && ruleForm.enclosure_file"
- class="clearfix tl"
- >
- <a
- :href="ruleForm.enclosure_file"
- download="附件"
- class="fl"
- >点击下载</a
- >
- <el-link
- :underline="false"
- @click="deleteUrl()"
- type="warning"
- style="margin: 0 0 0 16px"
- class="fr"
- >删除</el-link
- >
- </div>
- <div class="activity-upload" v-else>
- <div class="btnupload" style="position: relative">
- <i class="el-icon-plus avatar-uploader-icon"></i>
- <file-upload-pdf
- class="Upload"
- :accept="'.zip,.rar,.7z,.doc,.docx,.xlsx,.xls,.pdf'"
- :multiple="false"
- :uploadcondition="beforeOtherUpload"
- @UploadErrorEvent="UploadErrorOtherenclosure_file"
- @UploadSuccessEvent="
- UploadSuccessOtherenclosure_file
- "
- />
- </div>
- <div class="txt-tips fl">
- <p>建议大小:小于5MB</p>
- <p>文件格式:.zip,.rar,.7z</p>
- <p>.doc,.docx,.xlsx,.xls,.pdf</p>
- </div>
- </div>
- </el-form-item>
- </el-col>
- <el-col :span="8" v-if="is_noble">
- <el-form-item label="金属种类" prop="metal_id">
- <search-metal-kind
- :value="ruleForm.metal_id"
- :size="'mini'"
- :isDetail="listindex !== '-1'"
- :placeholder="'贵金属种类'"
- @searchChange="noble_metalsearchChange"
- />
- </el-form-item>
- <el-form-item
- v-if="ruleForm.is_gold_price === '1'"
- label="当前金价"
- prop="gold_price"
- style="margin: 0 0 0 0"
- >
- <el-input
- v-model="ruleForm.gold_price"
- disabled
- placeholder="当前金价"
- maxlength="500"
- >
- <template slot="append">元</template></el-input
- >
- </el-form-item>
- </el-col>
- <el-col :span="16" v-if="is_noble">
- <el-form-item
- label="其他配置要求"
- prop="other_config"
- label-width="120px"
- >
- <el-input
- v-model="ruleForm.other_config"
- type="textarea"
- :rows="2"
- placeholder="其他配置要求"
- maxlength="250"
- show-word-limit
- />
- </el-form-item>
- </el-col>
- <el-col :span="8" class="fr" style="padding: 18px 0 0 0">
- <el-button
- v-if="id !== '007'"
- type="primary"
- :size="'mini'"
- @click="submitForm"
- >保 存
- </el-button>
- <el-button :size="'mini'" @click="showModelThis = false">{{
- id == "007" ? "关 闭" : "取 消"
- }}</el-button></el-col
- >
- </el-row>
- </el-col>
- </el-row>
- </el-form>
- </el-col>
- </el-row>
- </el-card>
- </el-dialog>
- </template>
- <script>
- import asyncRequest from "@/apis/service/sellOut/zixunOrder";
- import resToken from "@/mixins/resToken";
- import { rules } from "../columns";
- import baseFormAddEdit from "./baseFormAddEdit";
- export default {
- name: "brand",
- props: ["showModel", "id", "sitem"],
- mixins: [resToken],
- components: {
- baseFormAddEdit,
- },
- data() {
- return {
- modelIndex: "",
- modelSitem: {},
- showOtherModel: false,
- spec_tableData: [],
- loading: false,
- is_noble: false,
- is_addrs_options: [
- { value: "0", label: "一地" },
- { value: "1", label: "多地" },
- ],
- is_custom_options: [
- { value: "0", label: "非定制" },
- { value: "1", label: "定制" },
- ],
- is_gold_price_options: [
- { value: "0", label: "不启用" },
- { value: "1", label: "启用" },
- ],
- config_options: ["证书", "包装盒", "绒布袋", "标签", "其他"],
- title: "添加咨询商品",
- showModelThis: this.showModel,
- pickerOptions: {
- disabledDate(time) {
- return time.getTime() <= Date.now();
- },
- },
- ruleForm: {
- p_cat_info: [],
- p_cat_id: "",
- p_budget_price: "",
- p_pgNo: "",
- p_num: "",
- p_good_type: "",
- p_good_name: "",
- p_good_img: "",
- pgNo: "",
- arrival_time: "",
- budget_price: "0.00",
- num: "0",
- brand_id: [],
- cat_id: [],
- unit: [],
- good_img: "",
- good_name: "",
- total_weight: "0.000",
- is_addrs: "",
- is_custom: "",
- is_gold_price: "",
- config: [],
- specs_weight: "0.000",
- other_config: "",
- cost_desc: "",
- use_desc: "",
- remark: "",
- metal_id: "",
- gold_price: "0",
- enclosure_file: "",
- },
- rulesThis: this.rules,
- rules: rules,
- listindex: "-1",
- };
- },
- watch: {
- showModel: function (val) {
- this.showModelThis = val;
- if (val) {
- this.initForm();
- }
- },
- showModelThis(val) {
- if (!val) {
- this.$emit("cancel");
- }
- },
- },
- methods: {
- async initForm() {
- this.loading = true;
- const { index } = this.sitem;
- this.listindex = index + "";
- if (this.listindex === "-1") {
- this.title = "添加咨询商品";
- } else {
- this.title = "修改咨询商品";
- }
- this.rulesThis = this.rules;
- await this.resetForm();
- this.loading = false;
- },
- openEdit(index, sitem) {
- this.modelIndex = index;
- this.modelSitem = sitem;
- this.showOtherModel = true;
- },
- openDelete(index) {
- this.spec_tableData.splice(index, 1);
- },
- //规格编辑修改结果
- refreshEdit(e) {
- let item = JSON.parse(JSON.stringify(e));
- const { index, id, specid, spec_name, spec_value_id, spec_value_name } =
- item;
- if (index + "" === "-1") {
- this.spec_tableData.push(item);
- } else {
- this.spec_tableData.forEach((i, findex) => {
- if (i.spec_id === spec_id) {
- this.spec_tableData[findex].id = id;
- this.spec_tableData[findex].specid = specid;
- this.spec_tableData[findex].spec_name = spec_name;
- this.spec_tableData[findex].spec_value_id = spec_value_id;
- this.spec_tableData[findex].spec_value_name = spec_value_name;
- }
- });
- }
- this.showOtherModel = false;
- },
- async resetForm() {
- this.spec_tableData = [];
- // 重置
- await this.$nextTick(() => {
- if (this.$refs.ruleForm) {
- this.$refs.ruleForm.resetFields();
- this.$refs.ruleForm.clearValidate();
- const { index } = this.sitem;
- let fi = index ? index + "" : "";
- const {
- pgNo,
- arrival_time,
- budget_price,
- num,
- brand_id,
- cat_id,
- good_img,
- good_name,
- total_weight,
- is_addrs,
- is_custom,
- is_gold_price,
- config,
- specs_weight,
- other_config,
- cost_desc,
- use_desc,
- remark,
- metal_id,
- gold_price,
- unit,
- unit_name,
- p_cat_info,
- p_cat_id,
- p_budget_price,
- p_pgNo,
- p_num,
- p_good_type,
- p_good_name,
- p_good_img,
- p_arrtime,
- brand_name,
- specinfo,
- cat_id_name,
- cat_arr_id,
- enclosure_file,
- } = this.sitem;
- console.log(this.sitem);
- // console.log(p_cat_info);
- let asd = [];
- if (p_cat_info && p_cat_info.length > 0) {
- p_cat_info.forEach((sd) => {
- asd.push(sd.id);
- });
- }
- if (specinfo && specinfo.length > 0) {
- this.spec_tableData = JSON.parse(JSON.stringify(specinfo));
- } else {
- this.spec_tableData = [];
- }
- this.ruleForm = {
- p_cat_info: p_cat_info,
- p_cat_id: p_cat_id,
- p_cat_arr_id: asd,
- p_budget_price: p_budget_price,
- p_pgNo: p_pgNo,
- p_num: p_num,
- p_good_type: p_good_type,
- p_good_name: p_good_name,
- p_good_img: p_good_img,
- p_arrtime: p_arrtime,
- pgNo: fi === "-1" && p_pgNo ? p_pgNo : pgNo || "",
- arrival_time:
- fi === "-1" && p_pgNo ? p_arrtime : arrival_time || "",
- budget_price:
- fi === "-1" && p_pgNo ? p_budget_price : budget_price || "0.00",
- num: fi === "-1" && p_pgNo ? p_num : num || "0",
- brand_id: brand_id ? brand_id : [],
- brand_name: brand_name ? brand_name : "",
- cat_id: cat_id ? cat_id : [],
- cat_arr_id: cat_arr_id ? cat_arr_id : [],
- cat_id_name: cat_id_name ? cat_id_name : "",
- good_img: fi === "-1" && p_pgNo ? p_good_img : good_img || "",
- good_name: fi === "-1" && p_pgNo ? p_good_name : good_name || "",
- total_weight: total_weight || "0",
- is_addrs: is_addrs || "0",
- is_custom: is_custom || "0",
- is_gold_price: is_gold_price || "0",
- config: config ? config : [],
- specs_weight: specs_weight || "0.000",
- other_config: other_config || "",
- cost_desc: cost_desc || "",
- use_desc: use_desc || "",
- remark: remark || "",
- metal_id: metal_id || "",
- gold_price: gold_price || "0",
- unit: unit ? unit : [],
- unit_name: unit_name ? unit_name : "",
- enclosure_file: enclosure_file || "",
- };
- this.is_noble = false;
- if (cat_arr_id && cat_arr_id.length > 0) {
- cat_arr_id.forEach((e) => {
- if (e === "6") {
- this.is_noble = true;
- }
- });
- }
- }
- });
- },
- //商品分类选择
- async goods_class_change(e) {
- const { code, pid, id, label, item } = e;
- this.ruleForm.cat_id = id ? [id] : [];
- this.ruleForm.cat_id_name = label ? label : "";
- this.ruleForm.cat_arr_id = item;
- this.$refs.ruleForm.validateField("cat_id");
- this.is_noble = pid === "6";
- },
- //单位选择
- unitsearchChange(e) {
- const { code, label } = e;
- this.ruleForm.unit = code ? [code] : [];
- this.ruleForm.unit_name = label ? label : "";
- this.$refs.ruleForm.validateField("unit");
- },
- //购买数量
- num_change(e, key) {
- this.ruleForm[key] = e + "";
- this.$refs.ruleForm.validateField(key);
- },
- //品牌选择
- brand_id_searchChange(e) {
- const { id, label } = e;
- this.ruleForm.brand_id = id ? [id] : [];
- this.ruleForm.brand_name = label ? label : "";
- this.$refs.ruleForm.validateField("brand_id");
- },
- //贵金属种类选择
- async noble_metalsearchChange(e) {
- const { id, price } = e;
- this.ruleForm.metal_id = id ? id : "";
- this.$refs.ruleForm.validateField("metal_id");
- console.log("change_metal_id");
- await this.get_golpricelast();
- // this.ruleForm.gold_price = price ? price : "0";
- },
- async get_golpricelast() {
- const { metal_id } = this.ruleForm;
- if (metal_id) {
- let model = {
- type: metal_id,
- };
- const { code, data, message } = await asyncRequest.golpricelast(model);
- if (code === 0) {
- data.forEach((e) => {
- if (e.type) {
- this.ruleForm.gold_price = e.price;
- }
- });
- } else if (code >= 100 && code <= 104) {
- await this.logout();
- } else {
- this.$message.warning(message);
- }
- } else {
- this.ruleForm.gold_price = "0";
- }
- this.$refs.ruleForm.validateField("gold_price");
- },
- async submitForm() {
- await this.$refs.ruleForm.validate(async (valid) => {
- if (valid) {
- this.loading = true;
- if (this.spec_tableData.length === 0) {
- this.$message.warning("请选择商品规格!");
- this.loading = false;
- return;
- }
- let model = JSON.parse(JSON.stringify(this.ruleForm));
- console.log(model.cat_arr_id);
- const { cat_arr_id } = model;
- const { total_weight, specs_weight, p_cat_info } = model;
- if (p_cat_info && p_cat_info.length > 0) {
- let length = p_cat_info.length;
- let car_name = "";
- p_cat_info.forEach((e, ei) => {
- car_name += `${ei !== 0 ? "_" : ""}${e.name}`;
- });
- let isok = true;
- for (let i = 0; i < length; i++) {
- if (p_cat_info[i].id !== cat_arr_id[i]) {
- isok = false;
- }
- }
- if (!isok) {
- this.$message.warning(
- `商品分类不符合项目商品要求,商品要求中的分类为:${car_name}!`
- );
- this.loading = false;
- return;
- }
- }
- console.log(p_cat_info);
- if (total_weight * 1000 < specs_weight * 1000 && this.is_noble) {
- this.$message.warning("商品总重量不能小于贵金属重量!");
- this.loading = false;
- return;
- }
- model.index = this.listindex;
- model.specinfo = JSON.parse(JSON.stringify(this.spec_tableData));
- this.loading = false;
- this.showModelThis = false;
- // 刷新
- this.$emit("refresh", model);
- } else {
- console.log("error submit!!");
- return false;
- }
- });
- },
- //判断图片规格
- beforeAvatarUpload(file) {
- let isJPG = false,
- isLt2M = false;
- if (file) {
- if (
- file.type === "image/jpg" ||
- file.type === "image/png" ||
- file.type === "image/jpeg"
- ) {
- isJPG = true;
- }
- isLt2M = file.size / 1024 / 1024 < 1;
- if (!isJPG) {
- this.$message.error("图片格式不正确!");
- }
- if (!isLt2M) {
- this.$message.error("图片大小不能超过 1MB!");
- }
- }
- return isJPG && isLt2M;
- },
- //图片上传失败
- UploadErrorEvent(res) {
- if (res !== "break") {
- this.$message.error("图片上传失败!");
- this.ruleForm.good_img = "";
- this.$refs.ruleForm.validateField("good_img");
- }
- },
- //图片上传成功
- async UploadSuccessEvent(data) {
- const { url } = data;
- if (url === "noToken") {
- await this.logout();
- } else {
- this.ruleForm.good_img = url;
- this.$message.success("图片上传成功!");
- this.$refs.ruleForm.validateField("good_img");
- }
- },
- //其他文件上传失败
- UploadErrorOtherenclosure_file(res) {
- if (res !== "break") {
- this.$refs.ruleForm.validateField("enclosure_file");
- }
- },
- //判断其他文件规格
- beforeOtherUpload(file) {
- console.log(file.type);
- let isJPG = false;
- if (
- file.type === "application/msword" ||
- file.type ===
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ||
- file.type === "application/vnd.ms-excel" ||
- file.type ===
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ||
- file.type === "application/pdf" ||
- file.type === "application/x-zip-compressed"
- ) {
- isJPG = true;
- }
- let name = file.name;
- let list = name.split(".");
- if (list[list.length - 1] === "rar" || list[list.length - 1] === "7z") {
- isJPG = true;
- }
- const isLt2M = file.size / 1024 / 1024 < 5;
- if (!isJPG) {
- this.$message.error("文件格式不正确!");
- }
- if (!isLt2M) {
- this.$message.error("文件大小不能超过 5MB!");
- }
- return isJPG && isLt2M;
- },
- deleteUrl() {
- this.ruleForm.enclosure_file = "";
- this.$refs.ruleForm.validateField("enclosure_file");
- },
- // 其他文件上传成功
- async UploadSuccessOtherenclosure_file(data) {
- const { url } = data;
- console.log(url);
- if (url === "noToken") {
- await this.logout();
- } else {
- this.ruleForm.enclosure_file = url;
- this.$message.success("附件上传成功!");
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .brand {
- }
- </style>
|