123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- <template>
- <el-form
- ref="ruleForm"
- :model="ruleForm"
- status-icon
-
- :size="'mini'"
- :rules="rulesThis"
- label-width="112px"
- >
- <el-row>
- <el-col :span="12">
- <el-form-item label="实时金价" prop="gold_price">
- <digital-input
- :values="ruleForm.gold_price"
- :placeholder="'修改实时金价'"
- :min="0"
- :max="100000000000"
- :position="'right'"
- :precision="2"
- :size="'mini'"
- :newTime="newTime"
- :controls="false"
- :append="'元'"
- @reschange="rate_change"
- />
- </el-form-item>
- </el-col>
- <el-col
- :span="12"
- style="text-align: right"
-
- >
- <el-button type="primary" :size="'mini'" @click="submitForm"
- >保 存
- </el-button>
- </el-col>
- </el-row>
- </el-form>
- </template>
- <script>
- import asyncRequest from "@/apis/service/purchaseIn/purchaseOrder";
- import resToken from "@/mixins/resToken";
- export default {
- name: "Account",
- props: ["showModel", "sitem", "id", "type",'newTime',"cost_detailArr"],
- mixins: [resToken],
- computed: {
- powers() {
- const tran =
- this.$store.getters.btnList.find(
- (item) => item.menu_route == "projectDetail"
- ) || {};
- const { action } = tran ?? {};
- return action ?? [];
- },
- },
- watch: {
- // showModel: function (val) {
- // this.showModelThis = val;
- // if (val) {
- // this.initForm();
- // }
- // },
- // newTime: function (val) {
- // if (val) {
- // this.initForm();
- // }
- // },
- },
- data() {
- const validate_sale_price = (rule, value, callback) => {
- if (value === "" || value === undefined) {
- callback(new Error("实时金价不能为空!"));
- } else if (
- value === "0" ||
- value === "0." ||
- value === "0.0" ||
- value === "0.00"
- ) {
- callback(new Error("实时金价不能为零!"));
- } else {
- callback();
- }
- };
- return {
- cost_detailArr:[],
- loading: false,
- ruleForm: {
- cgdNo: "",
- gold_price: "0",
- },
- rulesThis: this.rules,
- rules: {
- gold_price: [
- {
- required: true,
- validator: validate_sale_price,
- trigger: "blur",
- },
- ],
- },
- newTime:""
- };
- },
- mounted() {
- this.initForm();
- },
- methods: {
- //项目毛利率编辑
- rate_change(e) {
- this.ruleForm.gold_price = e ;
- this.ruleForm.cgdNo = this.sitem.cgdNo;
-
-
-
- this.$refs.ruleForm.validateField("gold_price");
- },
- //初始化整个组件
- async initForm() {
- // this.loading = true;
- console.log(this.sitem)
- this.company = "";
-
- this.ruleForm = {
- cgdNo: this.sitem.cgdNo,
- gold_price: this.sitem.gold_price,
- };
- console.log(this.ruleForm )
- this.rulesThis = this.rules;
- this.newTime = new Date().valueOf()+""
- console.log(this.newTime )
- //新增商品信息请求
- // const res = await asyncRequest.cost_detail({ spuCode: this.sitem.spuCode });
- // if (res && res.code === 0 && res.data) {
- // this.cost_detailArr = res.data;
- // console.log(this.cost_detailArr)
- // } else if (res && res.code >= 100 && res.code <= 104) {
- // await this.logout();
- // } else {
- // this.$message.warning(res.message);
- // }
-
- // this.loading = false;
- },
- //初始化整个表单
- // async resetForm() {
- // // 重置
- // await this.$nextTick(() => {
- // if (this.$refs.ruleForm) {
- // this.$refs.ruleForm.resetFields();
- // this.$refs.ruleForm.clearValidate();
- // const { low_rate, cgdNo, status } = this.sitem;
- // this.status = status || "";
- // this.ruleForm = {
- // cgdNo: cgdNo || "",
- // gold_price: low_rate || "0",
- // };
- // }
- // });
- // },
- async submitForm() {
- await this.$refs.ruleForm.validate(async (valid) => {
- console.log(valid)
- if (valid) {
- if (this.loading) {
- return;
- }
- this.loading = true;
- let model = JSON.parse(JSON.stringify(this.ruleForm));
- let res = await asyncRequest.cgdeditgoldprice(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>
|