ZeroChangeDialog.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <el-dialog title="客户信息编辑" v-model="visible" :width="width" append-to-body draggable @close="close">
  3. <!-- <div slot="title" class="dialog-title-container">
  4. <span class="title-label"><i class="el-icon-document" /> 工资信息</span>
  5. <i class="el-icon-close" @click="close" />
  6. </div> -->
  7. <!-- 功能按钮 -->
  8. <div style="padding: 8px 24px 16px 24px">
  9. <el-form size="small" label-width="100px" v-model="form">
  10. <el-row :gutter="30">
  11. <el-col :span="12">
  12. <el-form-item label="客户名称">
  13. <div>{{ form.name }}</div>
  14. </el-form-item>
  15. </el-col>
  16. <el-col :span="12">
  17. <el-form-item label="是否零申报">
  18. <el-select v-model="form.isZero" placeholder="请选择" style="width: 100%">
  19. <el-option v-for="item in yesOrNo" :key="item.label" :label="item.label" :value="item.value" />
  20. </el-select>
  21. </el-form-item>
  22. </el-col>
  23. </el-row>
  24. </el-form>
  25. </div>
  26. <div class="form-btns-container" style="height: 40px">
  27. <el-button size="small" style="float: right" @click="close" icon="close">
  28. 取消</el-button>
  29. <el-button type="primary" icon="Finished" size="small" style="float: right; margin-left: 12px; margin-right: 12px"
  30. @click="handleSave">保存</el-button>
  31. </div>
  32. </el-dialog>
  33. </template>
  34. <script setup>
  35. import {
  36. getCompany,
  37. addCompany,
  38. updateCompany,
  39. } from "@/api/business/crm/company";
  40. import { yesOrNo } from "@/utils/default";
  41. import { ref } from "vue";
  42. const { proxy } = getCurrentInstance();
  43. const visible = ref(false);
  44. const width = ref(800);
  45. const editStatus = ref(false);
  46. const baseUrl = ref(import.meta.env.VITE_APP_BASE_API);
  47. const defaultIsZero = ref(null);
  48. const props = defineProps({
  49. saveCallBack: {
  50. type: Function,
  51. default: () => { },
  52. },
  53. });
  54. const { saveCallBack } = toRefs(props);
  55. const total = ref(0);
  56. const form = ref({});
  57. const saveValue = ref(null);
  58. const emptyForm = {
  59. details: [],
  60. };
  61. function open(companyId, row) {
  62. saveValue.value = row;
  63. reset();
  64. visible.value = true;
  65. if (companyId) {
  66. getCompany(companyId).then((response) => {
  67. form.value = response.data;
  68. defaultIsZero.value = response.data.isZero;
  69. });
  70. }
  71. }
  72. function close() {
  73. visible.value = false;
  74. reset();
  75. }
  76. function reset() {
  77. form.value = proxy.deepClone(emptyForm);
  78. }
  79. function handleSave() {
  80. if (checkZero()) {
  81. proxy.$modal.confirm("确定修改么?").then((_) => {
  82. if (form.value.id) {
  83. updateCompany(form.value).then((response) => {
  84. proxy.$modal.msgSuccess("保存成功!");
  85. form.value = response.data;
  86. defaultIsZero.value = Number(response.data.isZero);
  87. saveCallBack.value(saveValue.value);
  88. close();
  89. });
  90. } else {
  91. addCompany(form.value).then((res) => {
  92. proxy.$modal.msgSuccess("保存成功!");
  93. form.value = response.data;
  94. defaultIsZero.value = Number(response.data.isZero);
  95. saveCallBack.value(saveValue.value);
  96. close();
  97. });
  98. }
  99. });
  100. }
  101. }
  102. function checkZero() {
  103. if (form.value.isZero == null) {
  104. proxy.$modal.msgError("请选择是否零申报");
  105. return false;
  106. }
  107. if (defaultIsZero.value === 1 || defaultIsZero.value == null) {
  108. return true;
  109. } else if (
  110. defaultIsZero.value != form.value.isZero &&
  111. form.value.isZero === 1
  112. ) {
  113. proxy.$modal.msgError("不可将非零申报客户改为零申报");
  114. return false;
  115. } else {
  116. return true;
  117. }
  118. }
  119. // 暴露给父组件的方法
  120. defineExpose({
  121. open,
  122. });
  123. </script>
  124. <style scoped>
  125. .img {
  126. width: 23px;
  127. height: 23px;
  128. display: flex;
  129. justify-content: center;
  130. align-items: center;
  131. }
  132. ::v-deep(.el-upload) {
  133. display: flex;
  134. text-align: center;
  135. justify-content: center;
  136. cursor: pointer;
  137. outline: 0;
  138. }
  139. .required::after {
  140. content: "*";
  141. color: red;
  142. }
  143. </style>