|  | @@ -6,67 +6,74 @@
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import { ElMessage, FormInstance, FormRules } from 'element-plus';
 | 
	
		
			
				|  |  | +import { Finished } from '@element-plus/icons-vue';
 | 
	
		
			
				|  |  | +import * as api from '../api';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -const loading = ref(false);
 | 
	
		
			
				|  |  | +const shopOptions = <Ref>inject('shopOptions');
 | 
	
		
			
				|  |  | +const groupOptions = <Ref>inject('groupOptions');
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const btnLoading = ref(false);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  const editOpen = defineModel({ default: false });
 | 
	
		
			
				|  |  | -const { rowData } = defineProps<{
 | 
	
		
			
				|  |  | -  rowData: object;
 | 
	
		
			
				|  |  | -}>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const props = defineProps({
 | 
	
		
			
				|  |  | +  rowData: Object
 | 
	
		
			
				|  |  | +});
 | 
	
		
			
				|  |  | +const { rowData } = props;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const emit = defineEmits([ 'refresh' ]);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  onBeforeMount(() => {
 | 
	
		
			
				|  |  | -  // replaceCol();
 | 
	
		
			
				|  |  |    console.log('rowData=> ', rowData);
 | 
	
		
			
				|  |  |  });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  interface RuleForm {
 | 
	
		
			
				|  |  | -  operatorName: any,
 | 
	
		
			
				|  |  | -  country: any
 | 
	
		
			
				|  |  | +  sku: any,
 | 
	
		
			
				|  |  | +  shop_name: any,
 | 
	
		
			
				|  |  | +  shop_id: any,
 | 
	
		
			
				|  |  | +  tag: any,
 | 
	
		
			
				|  |  | +  show_price: any,
 | 
	
		
			
				|  |  | +  activity_price: any,
 | 
	
		
			
				|  |  | +  minimum_price: any,
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const ruleFormRef = ref<FormInstance>();
 | 
	
		
			
				|  |  |  const ruleForm = reactive<RuleForm>({
 | 
	
		
			
				|  |  | -  operatorName: '',
 | 
	
		
			
				|  |  | -  country: ''
 | 
	
		
			
				|  |  | +  sku: rowData?.sku,
 | 
	
		
			
				|  |  | +  shop_name: rowData?.shop_name,
 | 
	
		
			
				|  |  | +  shop_id: rowData?.shop_id,
 | 
	
		
			
				|  |  | +  tag: rowData?.tag,
 | 
	
		
			
				|  |  | +  show_price: rowData?.show_price,
 | 
	
		
			
				|  |  | +  activity_price: rowData?.activity_price,
 | 
	
		
			
				|  |  | +  minimum_price: rowData?.minimum_price
 | 
	
		
			
				|  |  |  });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -const rules = reactive<FormRules<RuleForm>>({
 | 
	
		
			
				|  |  | -  operatorName: [
 | 
	
		
			
				|  |  | -    { message: 'Please input operator name', trigger: 'blur' }
 | 
	
		
			
				|  |  | -  ]
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -});
 | 
	
		
			
				|  |  | +const rules = reactive<FormRules<RuleForm>>({});
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const submitForm = async (formEl: FormInstance | undefined) => {
 | 
	
		
			
				|  |  |    if (!formEl) return;
 | 
	
		
			
				|  |  |    await formEl.validate(async (valid, fields) => {
 | 
	
		
			
				|  |  |      if (valid) {
 | 
	
		
			
				|  |  | -      // await useResponse({ id: gridOptions.data[0].id, partial: 1, formData: ruleForm }, api.updateShopDetail, loading);
 | 
	
		
			
				|  |  | -      editOpen.value = false;
 | 
	
		
			
				|  |  | -      ElMessage.success('编辑成功');
 | 
	
		
			
				|  |  | -      emit('refresh');
 | 
	
		
			
				|  |  | +      const body = {
 | 
	
		
			
				|  |  | +        id: rowData?.id,
 | 
	
		
			
				|  |  | +        ...ruleForm,
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      try {
 | 
	
		
			
				|  |  | +        const res = await useResponse( api.updateRow, body, btnLoading);
 | 
	
		
			
				|  |  | +        if (res && res.code == 2000) {
 | 
	
		
			
				|  |  | +          editOpen.value = false;
 | 
	
		
			
				|  |  | +          ElMessage.success('编辑成功');
 | 
	
		
			
				|  |  | +          emit('refresh');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +      } catch (error) {
 | 
	
		
			
				|  |  | +        console.error('Error==>', error);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  |      } else {
 | 
	
		
			
				|  |  |        console.log('error submit!', fields);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    });
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -const resetForm = (formEl: FormInstance | undefined) => {
 | 
	
		
			
				|  |  | -  if (!formEl) return;
 | 
	
		
			
				|  |  | -  formEl.resetFields();
 | 
	
		
			
				|  |  | -};
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -// function replaceCol() {
 | 
	
		
			
				|  |  | -//   const result = Object.keys(ruleForm).reduce((acc, key) => {
 | 
	
		
			
				|  |  | -//     if (key in gridOptions.data[0]) {
 | 
	
		
			
				|  |  | -//       acc[key] = gridOptions.data[0][key];
 | 
	
		
			
				|  |  | -//     }
 | 
	
		
			
				|  |  | -//     return acc;
 | 
	
		
			
				|  |  | -//   }, {} as { [key: string]: any });
 | 
	
		
			
				|  |  | -//   Object.assign(ruleForm, result);
 | 
	
		
			
				|  |  | -// }
 | 
	
		
			
				|  |  |  </script>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  <template>
 | 
	
	
		
			
				|  | @@ -82,25 +89,35 @@ const resetForm = (formEl: FormInstance | undefined) => {
 | 
	
		
			
				|  |  |          class="mx-2.5 mt-2.5"
 | 
	
		
			
				|  |  |          label-width="auto"
 | 
	
		
			
				|  |  |          status-icon>
 | 
	
		
			
				|  |  | -      <el-form-item label="运营" prop="operatorName">
 | 
	
		
			
				|  |  | -        <el-input v-model="ruleForm.operatorName"/>
 | 
	
		
			
				|  |  | +      <el-form-item label="SKU" prop="sku">
 | 
	
		
			
				|  |  | +        <el-input v-model="ruleForm.sku" />
 | 
	
		
			
				|  |  |        </el-form-item>
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -      <el-form-item label="国家" prop="country">
 | 
	
		
			
				|  |  | -        <!--<el-select v-model="ruleForm.country" placeholder="请选择线路">-->
 | 
	
		
			
				|  |  | -        <!--  <el-option-->
 | 
	
		
			
				|  |  | -        <!--      v-for="item in rowData.country"-->
 | 
	
		
			
				|  |  | -        <!--      :key="item"-->
 | 
	
		
			
				|  |  | -        <!--      :label="item"-->
 | 
	
		
			
				|  |  | -        <!--      :value="item">-->
 | 
	
		
			
				|  |  | -        <!--  </el-option>-->
 | 
	
		
			
				|  |  | -        <!--</el-select>-->
 | 
	
		
			
				|  |  | +      <el-form-item label="店 铺" prop="shop_name">
 | 
	
		
			
				|  |  | +        <el-select v-model="ruleForm.shop_name">
 | 
	
		
			
				|  |  | +          <el-option v-for="item in shopOptions" :key="item.id" :label="item.name" :value="item.id" />
 | 
	
		
			
				|  |  | +        </el-select>
 | 
	
		
			
				|  |  | +      </el-form-item>
 | 
	
		
			
				|  |  | +      <el-form-item label="分 组" prop="tag">
 | 
	
		
			
				|  |  | +        <el-select v-model="ruleForm.tag">
 | 
	
		
			
				|  |  | +          <el-option v-for="item in groupOptions" :label="item.tag" :value="item.tag" />
 | 
	
		
			
				|  |  | +        </el-select>
 | 
	
		
			
				|  |  | +      </el-form-item>
 | 
	
		
			
				|  |  | +      <el-form-item label="展示价格" prop="show_price">
 | 
	
		
			
				|  |  | +        <el-input v-model="ruleForm.show_price" />
 | 
	
		
			
				|  |  | +      </el-form-item>
 | 
	
		
			
				|  |  | +      <el-form-item label="平时活动售价" prop="activity_price">
 | 
	
		
			
				|  |  | +        <el-input v-model="ruleForm.activity_price" />
 | 
	
		
			
				|  |  | +      </el-form-item>
 | 
	
		
			
				|  |  | +      <el-form-item label="最低活动售价" prop="minimum_price">
 | 
	
		
			
				|  |  | +        <el-input v-model="ruleForm.minimum_price" />
 | 
	
		
			
				|  |  |        </el-form-item>
 | 
	
		
			
				|  |  |        <el-form-item>
 | 
	
		
			
				|  |  |          <el-divider />
 | 
	
		
			
				|  |  | -        <div class="flex flex-1 justify-center">
 | 
	
		
			
				|  |  | -          <el-button :loading="loading" type="primary" @click="submitForm(ruleFormRef)">确 定</el-button>
 | 
	
		
			
				|  |  | -          <el-button @click="resetForm(ruleFormRef)">重 置</el-button>
 | 
	
		
			
				|  |  | +        <div class="flex flex-1 justify-end">
 | 
	
		
			
				|  |  | +          <el-button :icon="Finished" :loading="btnLoading" plain type="primary" @click="submitForm(ruleFormRef)">
 | 
	
		
			
				|  |  | +            确 定
 | 
	
		
			
				|  |  | +          </el-button>
 | 
	
		
			
				|  |  | +          <!--<el-button @click="resetForm(ruleFormRef)">重 置</el-button>-->
 | 
	
		
			
				|  |  |          </div>
 | 
	
		
			
				|  |  |        </el-form-item>
 | 
	
		
			
				|  |  |      </el-form>
 |