costEdit.vue 2.45 KB
<template>
  <BasicDrawer
    v-cloakv-bind="$attrs"
    @register="register"
    title="编辑"
    width="35%"
    showFooter
    @ok="handleSubmit"
    ref="formRef"
    okText="保存"
    :destroyOnClose="true"
    :isDetail="true"
    :showDetailBack="false"
    :mask="false"
    class="z-20"
  >
    <a-space direction="vertical" style="width: 100%">
      <a-input v-model:value="fixCost" addonBefore="固定成本  " />
      <a-input v-model:value="ratio" addonBefore="提成比例  " />
      <a-input v-model:value="spainRatio" addonBefore="西班牙提成比例  " />
      <!-- <a-input v-model:value="price" addonBefore="生产提成单价" /> -->
    </a-space>
  </BasicDrawer>
</template>
<script lang="ts" setup>
  import { BasicDrawer, useDrawerInner } from '@/components/Drawer';
  import { BasicForm, FormSchema, useForm } from '@/components/Form';
  import { defineComponent, ref, computed, unref, toRaw, reactive, onMounted } from 'vue';
  import { saveConfig } from '/@/api/sys/config';

  // const emit = defineEmits(['success']);
  // const isUpdate = ref(true);
  const emit = defineEmits(['success']);

  const [register, { closeDrawer }] = useDrawerInner((data) => {
    listAll.value = data.data;
    console.log(listAll.value, '5656listAll.value');
    relationValue.value = JSON.parse(listAll.value.relationValue);
    fixCost.value = relationValue.value[0].relationValue;
    ratio.value = relationValue.value[1].relationValue;
    spainRatio.value = relationValue.value[2].relationValue;
    price.value = relationValue.value[3].relationValue;
  });
  //获取现有的列表
  const listAll = ref();
  const fixCost = ref();
  const ratio = ref();
  const spainRatio = ref();
  const price = ref();
  const relationValue = ref();

  //完成编辑
  async function handleSubmit() {
    relationValue.value[0].relationValue = fixCost.value;
    relationValue.value[1].relationValue = ratio.value;
    relationValue.value[2].relationValue = spainRatio.value;
    relationValue.value[3].relationValue = price.value;
    console.log(relationValue.value, '5656relationValue.value');
    await saveConfig({
      id: listAll.value.id,
      settingCode: 'customerCode',
      settingName: '客户提成成本配置',
      settingValue: listAll.value.settingValue,
      settingType: 3,
      relationCode: 'costSettingItem',
      relationName: '成本配置项集合',
      costSettingItemVOS: relationValue.value,
    });
    emit('success');
    closeDrawer();
  }
</script>