addPerson.vue 4.13 KB
<template>
  <a-modal
    :title="type=='add'?'新增注册人员':'编辑注册人员'"
    v-if="isVisible"
    v-model:visible="isVisible"
    width="800px"
    class="detail-modal"
  >
    <div>
        <a-form :model="formObj"  :label-col="{ style: { width: '100px' } }">
            <a-form-item label="姓名:">
                <a-input v-model:value="formObj.name" style="width: 500px">
                </a-input>
            </a-form-item>
            <a-form-item label="描述:">
                <a-input v-model:value="formObj.dec" style="width: 500px">
                </a-input>
            </a-form-item>
        </a-form>
    </div>
    <template #footer>
      <a-button @click="onCancel">返回</a-button>
      <a-button @click="onConfirm" type="primary">确定</a-button>
    </template>
  </a-modal>
</template>

<script>
import { reactive, ref,toRaw } from "vue";
import FeatureMatchingAccuracyApi from '@/views/FeatureMatchingAccuracy/FeatureMatchingAccuracyApi'
import {filterEmptyValueInObject, formatDate, formatTime, getPagedList} from '@/PublicUtil/PublicUtil'
import {ElMessage} from 'element-plus'
export default {
  setup(props,context) {
    const isVisible = ref(false);
    const pageNum = ref(1)
    const pageSize = ref(10)
    const total = ref()
    // 暂时选中目标,但没提交
    const checkList = ref([])
    const formObj = reactive({
        name: '',
        dec: '',
    })
    const isLoading = ref(false)
    const accountId = ref('');
    const mallId = ref('');
    const type = ref('')
    const initDialog = function(parmas) {
        accountId.value = parmas.account_id;
        mallId.value = parmas.plaza_id;
        type.value = parmas.type;
        formObj.name = parmas.name||'';
        formObj.dec = parmas.description||'';
        if(parmas.type=='edit'){
            formObj.id = parmas.id
        }
        isVisible.value = true;
    };
    const onCancel = () => {
        isVisible.value = false;
    };
    const refreshParentTable = function(){
        context.emit('refreshParentTable')
    }
    const onConfirm = function(){
        if(type.value=='add'){
            const data = filterEmptyValueInObject(
                {
                    accountId: accountId.value,
                    mallId: mallId.value,
                    name: formObj.name,
                    description: formObj.dec,
                }
            )
            FeatureMatchingAccuracyApi.addMatch(data).then(
                (r) => {
                    if(r.msg_code==200){
                        ElMessage({
                        	message: r.msg_info,
                        	type: 'success'
                        })
                        refreshParentTable()
                        isVisible.value = false
                    }else{
                        ElMessage({
                        	message: r.msg_info,
                        	type: 'error'
                        })
                        return false;
                    }
                }
            )
        }else{
            const data = filterEmptyValueInObject(
                {
                    accountId: accountId.value,
                    mallId: mallId.value,
                    name: formObj.name,
                    description: formObj.dec,
                    id: formObj.id,
                }
            )
            FeatureMatchingAccuracyApi.editMatch(data).then(
                (r) => {
                    if(r.msg_code==200){
                        ElMessage({
                        	message: r.msg_info,
                        	type: 'success'
                        })
                        refreshParentTable()
                        isVisible.value = false
                    }else{
                        ElMessage({
                        	message: r.msg_info,
                        	type: 'error'
                        })
                        return false;
                    }
                }
            )
        }
    }
    return {
        isVisible,
        formObj,
        onCancel,
        onConfirm,
        initDialog,
        isLoading,
        type
    };
  },
};
</script>
<style lang="less" scoped>
</style>