123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- <template>
- <el-dialog
- v-loading="loading"
- :title="'申请议价'"
- :center="true"
- align="left"
- top="10vh"
- width="750px"
- :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"
- >
- <el-card style="margin-top: -20px">
- <el-form
- ref="ruleForm"
- :model="ruleForm"
- status-icon
- :size="'mini'"
- :rules="rulesThis"
- label-width="80px"
- class="demo-ruleForm"
- >
- <el-row>
- <el-col :span="24">
- <el-form-item label="商品名称:">
- <el-input v-model="sitem.good_name" disabled />
- </el-form-item>
- </el-col>
- <el-col :span="3">
- <el-form-item label="图片:" style="margin: 0" label-width="44px">
- <img
- class="hover"
- v-viewer
- :src="sitem.good_img"
- alt=""
- v-if="sitem.good_img"
- style="width: 35px; height: 35px"
- />
- </el-form-item>
- </el-col>
- <el-col :span="4">
- <el-form-item label="单位:" label-width="50px">
- <el-input v-model="sitem.unit" disabled />
- </el-form-item>
- </el-col>
- <el-col :span="7">
- <el-form-item label="当前售价:">
- <el-input v-model="sitem.sale_price" disabled />
- </el-form-item>
- </el-col>
- <el-col :span="10">
- <el-form-item
- label="期望售价:"
- prop="bargain_price"
- label-width="95px"
- >
- <digital-input
- :values="ruleForm.bargain_price"
- :name="'ruleForm.bargain_price'"
- :placeholder="'期望售价'"
- :min="0"
- :disabled="false"
- :max="100000000000"
- :position="'right'"
- :precision="2"
- :size="'mini'"
- :controls="false"
- :append="'元'"
- @reschange="number_change($event, 'bargain_price')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="16">
- <el-form-item label="型号:" style="margin: 0">
- <span v-for="(si, sii) in sitem.specinfo" :key="sii + 'spec'"
- ><span v-if="sii !== 0">--</span>
- <span>{{ si.spec_name }}[{{ si.spec_value_name }}]</span>
- </span>
- </el-form-item>
- </el-col>
- <el-col :span="8" style="text-align: right">
- <el-button
- v-if="!isDetail"
- type="primary"
- :size="'mini'"
- @click="submitForm"
- >保 存
- </el-button>
- <el-button @click="showModelThis = false" :size="'mini'">{{
- isDetail ? "关 闭" : "取 消"
- }}</el-button>
- </el-col>
- </el-row>
- </el-form>
- </el-card>
- </el-dialog>
- </template>
- <script>
- import asyncRequest from "@/apis/service/sellOut/bargainList";
- import resToken from "@/mixins/resToken";
- export default {
- name: "Account",
- props: ["showModel", "sitem"],
- mixins: [resToken],
- data() {
- const validate_num = (rule, value, callback) => {
- if (value === "") {
- callback(new Error("不能为空!"));
- } else if (
- value === "0" ||
- value === "0." ||
- value === "0.0" ||
- value === "0.00"
- ) {
- callback(new Error("期望售价不能为零!"));
- } else {
- callback();
- }
- };
- return {
- roleList: [],
- loading: false,
- title: "添加账号",
- organizeList: [],
- showModelThis: this.showModel,
- ruleForm: {
- bargain_price: "0",
- },
- rulesThis: this.rules,
- rules: {
- bargain_price: [
- {
- required: true,
- validator: validate_num,
- trigger: "blur",
- },
- ],
- },
- };
- },
- watch: {
- showModel: function (val) {
- this.showModelThis = val;
- if (val) {
- this.initForm();
- }
- },
- showModelThis(val) {
- if (!val) {
- this.$emit("cancel");
- }
- },
- },
- mounted() {},
- methods: {
- itemidChange(e) {
- this.ruleForm.itemid = e;
- this.$refs.ruleForm.validateField("itemid");
- },
- async initForm() {
- this.loading = true;
- this.rulesThis = this.rules;
- await this.resetForm();
- this.loading = false;
- },
- number_change(e, key) {
- this.ruleForm[key] = e + "" || "0";
- this.$refs.ruleForm.validateField(key);
- },
- async resetForm() {
-
- await this.$nextTick(() => {
- if (this.$refs.ruleForm) {
- this.$refs.ruleForm.resetFields();
- this.$refs.ruleForm.clearValidate();
- this.ruleForm = {
- bargain_price: "0",
- };
- }
- });
- },
- async submitForm() {
- await this.$refs.ruleForm.validate(async (valid) => {
- if (valid) {
- this.loading = true;
- const { bargain_price } = JSON.parse(JSON.stringify(this.ruleForm));
- const { bidNo, sale_price } = this.sitem;
- if (sale_price * 100 === bargain_price * 100) {
- this.$message.warning("期望售价不能等于当前售价!");
- this.loading = false;
- return;
- }
- const model = {
- bidNo: bidNo,
- bargain_price: bargain_price,
- };
- let res = await asyncRequest.bargain_add(model);
- this.loading = false;
- if (res && res.code === 0) {
- this.$notify.success({
- title: "议价流程创建成功!",
- message: "",
- });
- this.showModelThis = false;
-
- this.$emit("refresh");
- } 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;
- }
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .account {
- }
- </style>
|