123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650 |
- <template>
- <el-form
- v-loading="loading"
- ref="ruleForm"
- :model="ruleForm"
- status-icon
- :rules="rulesThis"
- :label-width="labelWidth || '110px'"
- class="demo-ruleForm-goodsOnline"
- :size="'mini'"
- >
- <el-row>
- <el-col :span="24"
- ><el-form-item label="售价凭证类型" prop="proof_type">
- <el-radio-group
- v-model="ruleForm.proof_type"
- @change="set_proof_url()"
- >
- <el-radio
- v-for="item in options"
- :key="item.value"
- :label="item.value"
- >{{ item.label }}</el-radio
- >
- </el-radio-group>
- <el-button class="fr" type="primary" @click="showVoucher = true"
- >查看历史凭证</el-button
- >
- </el-form-item>
- <show-voucher-model
- :showModel="showVoucher"
- :id="spuCode"
- @cancel="showVoucher = false"
- @searchChange="resvoucher"
- />
- </el-col>
- <el-col :span="24">
- <el-form-item label="凭证文件" prop="proof_url">
- <ul class="shangchuan-ul">
- <li v-if="ruleForm.proof_type === '1'" class="shiping">
- <div v-if="video_url" class="clearfix">
- <video width="250" controls class="fl">
- <source :src="video_url" type="video/mp4" />
- <source :src="video_url" type="video/avi" />
- 您的浏览器不支持Video标签。
- </video>
- <el-link
- :underline="false"
- @click="deleteUrl('1')"
- type="warning"
- style="margin: 0 0 0 16px"
- >删除</el-link
- >
- </div>
- <div class="activity-upload" v-else>
- <div class="btnupload" style="position: relative">
- <i class="el-icon-plus avatar-uploader-icon"></i>
- <video-upload
- class="Upload"
- :disabled="type === 'view' || type === 'editCoin'"
- :accept="'.mp4,.avi'"
- :multiple="false"
- :uploadcondition="beforeVideoUpload"
- @UploadErrorEvent="UploadVideoEventproof_url"
- @UploadSuccessEvent="UploadSuccessVideoproof_url"
- />
- </div>
- <div class="txt-tips fl">
- <p>建议大小:小于10MB</p>
- <p>文件格式:.mp4,.avi</p>
- </div>
- </div>
- </li>
- <li v-if="ruleForm.proof_type === '2'" class="tupian">
- <div v-if="img_url" class="clearfix">
- <img
- style="width: 84px; height: 84px"
- :src="img_url"
- class="avatar fl"
- />
- <el-link
- :underline="false"
- @click="deleteUrl('2')"
- type="warning"
- style="margin: 0 0 0 16px"
- >删除</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
- class="Upload"
- :disabled="type === 'view' || type === 'editCoin'"
- :accept="'.jpg,.png,.jpeg'"
- :multiple="false"
- :uploadcondition="beforeAvatarUpload"
- @UploadErrorEvent="UploadErrorEventproof_url"
- @UploadSuccessEvent="UploadSuccessEventproof_url"
- ></file-upload>
- </div>
- <div class="txt-tips fl">
- <p>建议大小:小于1MB</p>
- <p>文件格式:.jpg,.png,.jpeg</p>
- </div>
- </div>
- </li>
- <li v-if="ruleForm.proof_type === '3'" class="qita">
- <div v-if="other_url" class="clearfix">
- <a :href="other_url" download="凭证文件">点击下载</a>
- <el-link
- :underline="false"
- @click="deleteUrl('3')"
- type="warning"
- style="margin: 0 0 0 16px"
- >删除</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="'.xlsx,.xls,.pdf,.zip,.rar,.7z'"
- :multiple="false"
- :uploadcondition="beforeOtherUpload"
- @UploadErrorEvent="UploadErrorOtherproof_url"
- @UploadSuccessEvent="UploadSuccessOtherproof_url"
- />
- </div>
- <div class="txt-tips fl">
- <p>建议大小:小于5MB</p>
- <p>文件格式:.xlsx,.xls,.pdf,.zip,.rar,.7z</p>
- </div>
- </div>
- </li>
- </ul>
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-table
- :data="ruleForm.good_ladder"
- :size="'mini'"
- border
- stripe
- style="width: 100%; margin: 0 0 20px 0"
- >
- <el-table-column prop="min_num" label="起订量(>=)" />
- <el-table-column prop="sale_price" label="售价" />
- <el-table-column prop="market_price" label="市场价" />
- <el-table-column prop="market_platform" label="对比平台" />
- <el-table-column prop="status" label="状态">
- <template slot-scope="scope">
- <el-tag
- :size="'mini'"
- :type="scope.row.status == '1' ? '' : 'warning'"
- >{{ scope.row.status == "1" ? "启用" : "禁用" }}</el-tag
- >
- </template>
- </el-table-column>
- <el-table-column fixed="right">
- <template slot="header" slot-scope="scope">
- <span>操作</span>
- <el-tooltip effect="dark" content="添加阶梯" placement="top">
- <i
- class="el-icon-circle-plus-outline tb-icon fr"
- @click="openCostEdit(-1, {})"
- ></i>
- </el-tooltip>
- </template>
- <template slot-scope="scope">
- <el-tooltip effect="dark" content="修改" placement="top">
- <i
- class="el-icon-edit tb-icon"
- @click="openCostEdit(scope.$index, scope.row)"
- ></i>
- </el-tooltip>
- <el-tooltip effect="dark" content="删除" placement="top">
- <i
- class="el-icon-delete tb-icon"
- @click="openCostEditDelete(scope.$index)"
- ></i>
- </el-tooltip>
- </template>
- </el-table-column>
- </el-table>
- <!-- 弹窗 新增/修改 -->
- <cost-form-add-edit
- :index="costmodelIndex"
- :show-model="costshowModel"
- :sitem="costsitem"
- :spuCode="spuCode"
- @refresh="costrefreshEdit"
- @cancel="costshowModel = false"
- />
- <el-form-item class="fr">
- <el-button
- v-if="!isDetail"
- :size="'mini'"
- type="primary"
- @click="submitForm"
- >保 存
- </el-button>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- </template>
- <script>
- import costFormAddEdit from "./costFormAddEdit";
- import asyncRequest from "@/apis/service/goodStore/goodsOnline";
- import showVoucherModel from "@/components/show-voucher-model";
- export default {
- name: "exam-form",
- props: [
- "size",
- "statusList",
- "disabled",
- "isMust",
- "labelWidth",
- "id",
- "spuCode",
- "sitem",
- ],
- components: {
- costFormAddEdit,
- showVoucherModel,
- },
- /**
- * 属性集合
- * @param {String} size : 组件大小 非必填
- * @param {Array} statusList : 驳回至备选项 必填
- * @param {Boolean} disabled : 是否禁用 必填
- * @param {Boolean} isMust : 是否需要展示驳回节点 必填
- *
- *
- */
- /**
- * 事件集合
- * @searchChange : 选中值变化调用 抛出选中数据
- */
- data() {
- return {
- loading: false,
- showVoucher: false,
- video_url: "",
- img_url: "",
- other_url: "",
- options: [
- {
- value: "1",
- label: "视频",
- },
- {
- value: "2",
- label: "图片",
- },
- {
- value: "3",
- label: "其他",
- },
- ],
- showModelThis: this.showModel,
- pickerOptions: {
- disabledDate(time) {
- return time.getTime() < Date.now() - 60 * 60 * 24 * 1000;
- },
- },
- costshowModel: false,
- costmodelIndex: "",
- costsitem: {},
- ruleForm: {
- skuCode: "",
- proof_type: "1", // 通过or驳回
- proof_url: "", //驳回至
- good_ladder: [],
- },
- rulesThis: this.rules,
- rules: {
- proof_type: [
- {
- required: true,
- message: "请选择审核状态",
- trigger: "change",
- },
- ],
- proof_url: [
- {
- required: true,
- message: "请上传凭证文件",
- trigger: "blur,change",
- },
- ],
- rebut: [
- {
- required: true,
- message: "请选择驳回节点",
- trigger: "change",
- },
- ],
- remark: [
- { required: true, message: "请输入审核备注", trigger: "blur" },
- {
- min: 1,
- max: 250,
- message: "长度在 1 到 250 个字符",
- trigger: "blur",
- },
- ],
- },
- };
- },
- watch: {
- isDetail: function (val, old) {
- if (this.isDetail !== val) {
- this.options = [];
- this.selectLoading = false;
- }
- },
- newTime: function (val) {
- if (val) {
- this.initForm();
- }
- },
- },
- mounted() {
- this.initForm();
- },
- methods: {
- async initForm() {
- console.log(this.spuCode);
- this.loading = true;
- await this.resetForm();
- this.rulesThis = this.rules;
- this.loading = false;
- },
- openCostEdit(index, sitem) {
- this.costmodelIndex = index;
- this.costsitem = sitem;
- this.costshowModel = true;
- },
- openCostEditDelete(index) {
- this.ruleForm.good_ladder.splice(index, 1);
- },
- //阶梯成本修改
- costrefreshEdit(e) {
- let item = JSON.parse(JSON.stringify(e));
- console.log(item);
- const {
- index,
- id,
- min_num,
- sale_price,
- market_price,
- market_platform,
- status,
- is_del,
- } = item;
- let ffindex = -1;
- this.ruleForm.good_ladder.forEach((i, findex) => {
- if (findex === parseInt(index + "")) {
- ffindex = findex;
- this.ruleForm.good_ladder[findex].id = id;
- this.ruleForm.good_ladder[findex].sale_price = sale_price;
- this.ruleForm.good_ladder[findex].market_price = market_price;
- this.ruleForm.good_ladder[findex].min_num = min_num;
- this.ruleForm.good_ladder[findex].market_platform = market_platform;
- this.ruleForm.good_ladder[findex].status = status;
- this.ruleForm.good_ladder[findex].id_del = is_del;
- }
- });
- if (ffindex === -1) {
- this.ruleForm.good_ladder.push(item);
- }
- this.showModel = false;
- },
- async resetForm() {
- // 重置
- await this.$nextTick(() => {
- if (this.$refs.ruleForm) {
- this.$refs.ruleForm.resetFields();
- this.$refs.ruleForm.clearValidate();
- const { proof, ladderlist } = this.sitem;
- this.ruleForm = {
- skuCode: this.id,
- proof_type: proof && proof.proof_type ? proof.proof_type : "1", // 通过or驳回
- proof_url: proof && proof.proof_url ? proof.proof_url : "", //驳回至
- good_ladder:
- ladderlist && ladderlist.length > 0
- ? JSON.parse(JSON.stringify(ladderlist))
- : [],
- };
- console.log(this.ruleForm.proof_url);
- switch (this.ruleForm.proof_type) {
- case "1":
- this.video_url = this.ruleForm.proof_url;
- break;
- case "2":
- this.img_url = this.ruleForm.proof_url;
- break;
- case "3":
- this.other_url = this.ruleForm.proof_url;
- break;
- default:
- this.video_url = this.ruleForm.proof_url;
- }
- this.$refs.ruleForm.validateField("proof_url");
- }
- });
- },
- async submitForm() {
- await this.$refs.ruleForm.validate(async (valid) => {
- if (valid) {
- let model = JSON.parse(JSON.stringify(this.ruleForm));
- let list = JSON.parse(JSON.stringify(model.good_ladder));
- let list2 = [];
- list.forEach((e) => {
- let n = JSON.parse(JSON.stringify(e));
- for (let key in n) {
- n[key] += "";
- }
- delete n["index"];
- list2.push(n);
- });
- model.good_ladder = list2;
- model.skuCode = this.id;
- let res = await asyncRequest.ladderOne(model);
- this.loading = false;
- if (res && res.code === 0) {
- this.$notify.success({
- title: "信息提交成功",
- message: "",
- });
- this.$emit("resSuccess", true);
- } else if (res && res.code >= 100 && res.code <= 104) {
- await this.logout();
- } else {
- this.$message.warning(res.message);
- }
- } else {
- console.log("error submit!!");
- return false;
- }
- });
- },
- resvoucher(e) {
- const { proof_type, proof_url } = e;
- this.ruleForm.proof_type = proof_type || "1";
- switch (this.ruleForm.proof_type) {
- case "1":
- this.video_url = proof_url;
- break;
- case "2":
- this.img_url = proof_url;
- break;
- case "3":
- this.other_url = proof_url;
- break;
- default:
- this.video_url = proof_url;
- }
- this.set_proof_url();
- },
- //图片上传成功
- async UploadSuccessEventproof_url(data) {
- const { url } = data;
- if (url === "noToken") {
- await this.logout();
- } else {
- this.img_url = url;
- this.set_proof_url();
- this.$message.success("图片上传成功!");
- }
- },
- //图片上传失败
- UploadErrorEventproof_url(res) {
- if (res !== "break") {
- this.set_proof_url();
- this.$message.error("图片上传失败!");
- }
- },
- //判断图片规格
- 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;
- },
- //视频上传成功
- async UploadSuccessVideoproof_url(data) {
- const { url } = data;
- if (url === "noToken") {
- await this.logout();
- } else {
- this.video_url = url;
- this.set_proof_url();
- this.$message.success("视频上传成功!");
- }
- },
- //视频上传失败
- UploadErrorVideoproof_url(res) {
- if (res !== "break") {
- this.set_proof_url();
- this.$message.error("视频上传失败!");
- }
- },
- //判断视频规格
- beforeVideoUpload(file) {
- let isJPG = false;
- if (file.type === "video/mp4" || file.type === "video/avi") {
- isJPG = true;
- }
- const isLt2M = file.size / 1024 / 1024 < 10;
- if (!isJPG) {
- this.$message.error("视频格式不正确!");
- }
- if (!isLt2M) {
- this.$message.error("视频大小不能超过 10MB!");
- }
- return isJPG && isLt2M;
- },
- // 其他文件上传成功
- async UploadSuccessOtherproof_url(data) {
- const { url } = data;
- if (url === "noToken") {
- await this.logout();
- } else {
- this.other_url = url;
- this.set_proof_url();
- this.$message.success("文件成功!");
- }
- },
- //其他文件上传失败
- UploadErrorOtherproof_url(res) {
- if (res !== "break") {
- this.set_proof_url();
- this.$message.error("文件上传失败!");
- }
- },
- //判断其他文件规格
- beforeOtherUpload(file) {
- console.log(file);
- let isJPG = false;
- if (
- 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(type) {
- switch (type) {
- case "1":
- this.video_url = "";
- break;
- case "2":
- this.img_url = "";
- break;
- case "3":
- this.other_url = "";
- break;
- default:
- this.video_url = "";
- }
- this.set_proof_url();
- },
- set_proof_url() {
- const { proof_type } = this.ruleForm;
- switch (proof_type) {
- case "1":
- this.ruleForm.proof_url = this.video_url;
- break;
- case "2":
- this.ruleForm.proof_url = this.img_url;
- break;
- case "3":
- this.ruleForm.proof_url = this.other_url;
- break;
- default:
- this.ruleForm.proof_url = this.video_url;
- }
- this.$refs.ruleForm.validateField("proof_url");
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .demo-ruleForm-goodsOnline {
- .shangchuan-ul {
- li {
- position: relative;
- width: 100%;
- &.tupian {
- }
- }
- }
- }
- </style>
|