<!--
 * @Descripttion: (商品/tb_goods 详情弹窗)
 * @version: (1.0)
 * @Author: (lwh)
 * @Date: (2023-06-19)
 * @LastEditors: (lwh)
 * @LastEditTime: (2023-06-19)
-->
 <template>
  <el-dialog v-model="props.modelValue" title="商品信息详情" width="900px" @closed="closeDialog" @open="openDialog">
    <el-form ref="formRef" :model="formData" :disabled="true">

      <el-row :gutter="20">
	  

    
    
    
          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="店铺guid" >
              <el-input v-model="formData.shopGuid"  />
            </el-form-item>
          </el-col>
    
          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="商品类目guid" >
              <el-input v-model="formData.goodsCategoryGuid"  />
            </el-form-item>
          </el-col>
    
          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="商品规格guid" >
              <el-input v-model="formData.goodsSkuGuid"  />
            </el-form-item>
          </el-col>
    
          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="配送模板guid" >
              <el-input v-model="formData.deliveryGuid"  />
            </el-form-item>
          </el-col>

          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="名称" >
              <el-input v-model="formData.goodsName"  />
            </el-form-item>
          </el-col>

          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="编码" >
              <el-input v-model="formData.goodsCoding"  />
            </el-form-item>
          </el-col>

          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="主图视频" >
              <UploadFile v-model="formData.goodsMainImageVideo" :data=imgData :isShowTip="false"/>
            </el-form-item>
          </el-col>

          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="视频封面" >
              <UploadImage ref="uploadRef" v-model="formData.goodsVideoCover" :limit="1" :fileSize="5"
              :drag="true" :isShowTip="false" :isDisabled="true"/>
            </el-form-item>
          </el-col>

          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="图片" >
              <UploadImage ref="uploadRef" v-model="formData.goodsPicture" :limit="1" :fileSize="5"
              :drag="true" :isShowTip="false" :isDisabled="true"/>
            </el-form-item>
          </el-col>

          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="价格(最低)" >
              <el-input-number v-model.number="formData.goodsPriceLowest" controls-position="right" :precision="2" />
            </el-form-item>
          </el-col>

          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="价格(最高)" >
              <el-input-number v-model.number="formData.goodsPriceHighest" controls-position="right" :precision="2" />
            </el-form-item>
          </el-col>

          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="划线价格(最低)" >
              <el-input-number v-model.number="formData.goodsDashedPriceLowest" controls-position="right" :precision="2" />
            </el-form-item>
          </el-col>
    
          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="库存总量" >
              <el-input-number v-model.number="formData.goodsTotalInventory" controls-position="right" :precision="2" />
            </el-form-item>
          </el-col>
    
          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="初始销量" >
              <el-input-number v-model.number="formData.goodsSalesInitial" controls-position="right" :precision="2" />
            </el-form-item>
          </el-col>
    
          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="实际销量" >
              <el-input-number v-model.number="formData.goodsSalesActual" controls-position="right" :precision="2" />
            </el-form-item>
          </el-col>

          <el-col :lg="24">
            <el-form-item :label-width="labelWidth" label="详情" >
              <editor v-model="formData.goodsDetails" :editorConfig="{ readOnly: true }" :min-height="200" />
            </el-form-item>
          </el-col>
    
          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="库存计算方式(1下单立减库存 2付款立减库存)" >
              <el-radio-group v-model="formData.goodsDeductStockType">
                <el-radio v-for="item in  deduct_stock_type " :key="item.dictValue" :label="parseInt(item.dictValue)">{{item.dictLabel}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
    
          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="是否赠送积分(1开启 0关闭)" >
              <el-radio-group v-model="formData.goodsIsPointsGift">
                <el-radio v-for="item in  is_points_gift " :key="item.dictValue" :label="parseInt(item.dictValue)">{{item.dictLabel}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
    
          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="是否允许使用积分抵扣(1允许 0不允许)" >
              <el-radio-group v-model="formData.goodsIsPointsDiscount">
                <el-radio v-for="item in  is_points_discount " :key="item.dictValue" :label="parseInt(item.dictValue)">{{item.dictLabel}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
    
          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="积分抵扣设置(0默认抵扣 1单独设置抵扣)" >
              <el-radio-group v-model="formData.goodsIsAlonePointsDiscount">
                <el-radio v-for="item in  is_alone_points_discount " :key="item.dictValue" :label="parseInt(item.dictValue)">{{item.dictLabel}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>

          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="单独设置积分抵扣的配置" >
              <el-input v-model="formData.goodsPointsDiscountConfig"  />
            </el-form-item>
          </el-col>
    
          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="是否开启会员折扣(1开启 0关闭)" >
              <el-radio-group v-model="formData.goodsIsEnableGrade">
                <el-radio v-for="item in  is_enable_grade " :key="item.dictValue" :label="parseInt(item.dictValue)">{{item.dictLabel}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
    
          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="会员折扣设置(0默认等级折扣 1单独设置折扣)" >
              <el-radio-group v-model="formData.goodsIsAloneGrade">
                <el-radio v-for="item in  is_alone_grade " :key="item.dictValue" :label="parseInt(item.dictValue)">{{item.dictLabel}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>

          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="单独设置折扣的配置" >
              <el-input v-model="formData.goodsAloneGradeEquity"  />
            </el-form-item>
          </el-col>
    
          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="上下架状态(1上架  2下架)" >
              <el-radio-group v-model="formData.goodsShelfStatus">
                <el-radio v-for="item in  shelf_status " :key="item.dictValue" :label="parseInt(item.dictValue)">{{item.dictLabel}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
    
          <el-col :lg="12">
            <el-form-item :label-width="labelWidth" label="排序" >
              <el-input-number v-model.number="formData.goodsSort" controls-position="right" :precision="2" />
            </el-form-item>
          </el-col>






      </el-row>
    </el-form>
  </el-dialog>
</template>

<script setup>
import { ElMessage } from 'element-plus'
import { reactive, ref, watch } from "vue";


// 打开弹窗时回调
const openDialog = async () => {
   await getdeduct_stock_type()
   await getis_points_gift()
   await getis_points_discount()
   await getis_alone_points_discount()
   await getis_enable_grade()
   await getis_alone_grade()
   await getshelf_status()

}

const formData = ref({
  ...props.data,
});
watch(props, async (v) => {
  formData.value = v.data;
});

// -业务参数
// 库存计算方式(1下单立减库存 2付款立减库存)字典选项列表
const deduct_stock_type = ref([]);
// 是否赠送积分(1开启 0关闭)字典选项列表
const is_points_gift = ref([]);
// 是否允许使用积分抵扣(1允许 0不允许)字典选项列表
const is_points_discount = ref([]);
// 积分抵扣设置(0默认抵扣 1单独设置抵扣)字典选项列表
const is_alone_points_discount = ref([]);
// 是否开启会员折扣(1开启 0关闭)字典选项列表
const is_enable_grade = ref([]);
// 会员折扣设置(0默认等级折扣 1单独设置折扣)字典选项列表
const is_alone_grade = ref([]);
// 上下架状态(1上架  2下架)字典选项列表
const shelf_status = ref([]);

// -业务方法
// 字典获取
async function getdeduct_stock_type() {
  await proxy.getDicts('deduct_stock_type').then((res) => {
    deduct_stock_type.value = res.data
  })
}
// 字典获取
async function getis_points_gift() {
  await proxy.getDicts('is_points_gift').then((res) => {
    is_points_gift.value = res.data
  })
}
// 字典获取
async function getis_points_discount() {
  await proxy.getDicts('is_points_discount').then((res) => {
    is_points_discount.value = res.data
  })
}
// 字典获取
async function getis_alone_points_discount() {
  await proxy.getDicts('is_alone_points_discount').then((res) => {
    is_alone_points_discount.value = res.data
  })
}
// 字典获取
async function getis_enable_grade() {
  await proxy.getDicts('is_enable_grade').then((res) => {
    is_enable_grade.value = res.data
  })
}
// 字典获取
async function getis_alone_grade() {
  await proxy.getDicts('is_alone_grade').then((res) => {
    is_alone_grade.value = res.data
  })
}
// 字典获取
async function getshelf_status() {
  await proxy.getDicts('shelf_status').then((res) => {
    shelf_status.value = res.data
  })
}



// 基础参数
const formRef = ref();
const labelWidth = 100;
const { proxy } = getCurrentInstance()
const props = defineProps({
  modelValue: Boolean,
  data: Object,
  done: Function,
});
const emits = defineEmits(["update:modelValue"]);


// -基础方法
const closeDialog = () => {
  emits("update:modelValue", false);
};

</script>
