| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <template>
- <div class="dialog">
- <el-dialog
- v-model="dialogVisible"
- :title="dialogTitle"
- width="480"
- @close="closeDialog()"
- >
- <el-form
- ref="formRef"
- :model="formData"
- :rules="rules"
- label-width="120px"
- >
- <el-row>
- <el-col :span="24">
- <el-form-item prop="clientName" label="客户名称">
- <el-input v-model="formData.clientName" />
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item prop="clientCode" label="客户编码">
- <el-input
- :disabled="formData.id > 0"
- v-model="formData.clientCode"
- />
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item prop="md5ParamDigest" label="通讯密钥">
- <el-input v-model="formData.md5ParamDigest" />
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item prop="contactPhone" label="联系电话">
- <el-input v-model="formData.contactPhone" />
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item prop="contactPerson" label="联系人">
- <el-input v-model="formData.contactPerson" />
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item prop="clientAddress" label="地址">
- <el-input v-model="formData.clientAddress" />
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item prop="erpServerUrl" label="erp服务器连接地址">
- <el-input v-model="formData.erpServerUrl" />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <template #footer>
- <div class="dialog-footer">
- <el-button v-throttle type="primary" @click="handleSubmit"
- >确 定
- </el-button>
- <el-button @click="closeDialog()">取 消</el-button>
- </div>
- </template>
- </el-dialog>
- </div>
- </template>
- <script setup lang="ts">
- import { addClientInfo, getERPClient, updateClientInfo } from "@/api/baseInfo";
- import type { FormInstance } from "element-plus";
- let dialogVisible = ref(false);
- let dialogTitle = ref("");
- const formRef = ref<FormInstance>();
- const emit = defineEmits(["dialogChange"]);
- const formData = reactive({
- contactPerson: "",
- contactPhone: "",
- clientAddress: "",
- clientName: "",
- clientCode: "",
- md5ParamDigest: "",
- erpServerUrl: "",
- id: 0,
- });
- const rules = reactive({
- clientName: [{ required: true, message: "请输入客户名称", trigger: "blur" }],
- });
- function handleSubmit() {
- formRef.value.validate((valid: any) => {
- if (valid) {
- const itemId = formData.id;
- if (itemId) {
- //修改
- const postData = JSON.stringify(formData);
- const params = {
- erpClient: postData,
- };
- updateClientInfo(params).then((response) => {
- dialogVisible.value = false;
- if (response.httpCode == 200) {
- emit("dialogChange");
- ElMessage.success("操作成功");
- }
- });
- } else {
- //增加
- const postData = JSON.stringify(formData);
- const params = {
- erpClient: postData,
- };
- addClientInfo(params).then((response) => {
- dialogVisible.value = false;
- if (response.httpCode == 200) {
- emit("dialogChange");
- ElMessage.success("操作成功");
- }
- });
- }
- }
- });
- }
- function getItemData(item) {
- const data = {
- idClient: item,
- };
- getERPClient(data).then((response) => {
- if (response.httpCode == 200) {
- const data = response.data;
- Object.assign(formData, { ...data });
- }
- });
- }
- /** 重置表单 */
- function resetForm() {
- formRef.value.resetFields();
- formData.id = "";
- }
- /**关闭弹窗 */
- function closeDialog() {
- dialogVisible.value = false;
- formRef.value.resetFields();
- formData.id = undefined;
- }
- defineExpose({
- dialogVisible,
- dialogTitle,
- getItemData,
- resetForm,
- });
- </script>
- <style scoped lang="scss"></style>
|