dialog.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <style scoped lang="scss">
  2. </style>
  3. <template>
  4. <div class="system-dialog-container">
  5. <el-drawer
  6. :title="state.dialog.title"
  7. v-model="state.dialog.isShowDialog"
  8. width="820px"
  9. append-to-body
  10. destroy-on-close
  11. :close-on-click-modal="false"
  12. >
  13. <el-form
  14. :model="state.form"
  15. :rules="rules"
  16. label-position="left"
  17. ref="formRef"
  18. size="default"
  19. label-width="100px"
  20. class="mt5">
  21. <el-input
  22. v-model="state.formQuery.adminUserId"
  23. placeholder="客户用户id"
  24. clearable
  25. class="wd150">
  26. </el-input>
  27. <el-input
  28. v-model="state.formQuery.adminUserName"
  29. placeholder="客户姓名"
  30. clearable
  31. class="wd150">
  32. </el-input>
  33. <el-input
  34. v-model="state.formQuery.stationId"
  35. placeholder="站点id"
  36. clearable
  37. class="wd150">
  38. </el-input>
  39. <el-input
  40. v-model="state.formQuery.vatRate"
  41. placeholder="增值税率 0.06表示6%"
  42. clearable
  43. class="wd150">
  44. </el-input>
  45. <el-input
  46. v-model="state.formQuery.splittingProportion"
  47. placeholder="分成比例 0.45表示45%"
  48. clearable
  49. class="wd150">
  50. </el-input>
  51. <el-input
  52. v-model="state.formQuery.accountName"
  53. placeholder="账户名"
  54. clearable
  55. class="wd150">
  56. </el-input>
  57. <el-input
  58. v-model="state.formQuery.telephone"
  59. placeholder="电话号码"
  60. clearable
  61. class="wd150">
  62. </el-input>
  63. <el-input
  64. v-model="state.formQuery.bankName"
  65. placeholder="开户行名称"
  66. clearable
  67. class="wd150">
  68. </el-input>
  69. <el-input
  70. v-model="state.formQuery.bankCardNo"
  71. placeholder="银行卡号"
  72. clearable
  73. class="wd150">
  74. </el-input>
  75. <el-input
  76. v-model="state.formQuery.status"
  77. placeholder="状态:0-无效,1-有效"
  78. clearable
  79. class="wd150">
  80. </el-input>
  81. <el-input
  82. v-model="state.formQuery.remark"
  83. placeholder="备注"
  84. clearable
  85. class="wd150">
  86. </el-input>
  87. </el-form>
  88. <template #footer>
  89. <div class="dialog-footer">
  90. <el-button @click="onCancel" size="default">取 消</el-button>
  91. <el-button :loading="state.btnLoading" type="primary" @click="onSubmit" size="default">{{ state.dialog.submitTxt }}</el-button>
  92. </div>
  93. </template>
  94. </el-drawer>
  95. </div>
  96. </template>
  97. <script setup lang="ts" name="InvestorInfoDialog">
  98. import {defineAsyncComponent, reactive, onMounted, ref} from 'vue';
  99. import {Msg} from "/@/utils/message";
  100. import {$body, $get} from "/@/utils/request";
  101. import u from '/@/utils/u'
  102. // 定义子组件向父组件传值/事件
  103. const emit = defineEmits(['refresh']);
  104. const formRef = ref();
  105. //定义初始变量,重置使用
  106. const initState = ()=>({
  107. ruleForm: {
  108. id:0
  109. },
  110. btnLoading: false,
  111. dialog: {
  112. isShowDialog: false,
  113. type: '',
  114. title: '',
  115. submitTxt: '',
  116. },
  117. rules: {},
  118. })
  119. // 定义变量内容
  120. const state = reactive(initState());
  121. // 打开弹窗
  122. const open = (action: string='add', row: any) => {
  123. state.dialog.title = u.dialog.actions[action].title +"『投资者-物业信息表』"
  124. state.dialog.submitTxt = u.dialog.actions[action].btn +"『投资者-物业信息表』"
  125. state.dialog.isShowDialog = true;
  126. if (action !=='add') {
  127. loadData(row.id);
  128. }
  129. };
  130. // 关闭弹窗
  131. const onClose = () => {
  132. state.dialog.isShowDialog = false;
  133. Object.assign(state,initState())
  134. };
  135. // 取消
  136. const onCancel = () => {
  137. onClose();
  138. };
  139. // 提交
  140. const onSubmit = () => {
  141. formRef.value.validate((valid, fields) => {
  142. // console.log('basic checkForm!', valid,fields)
  143. if (valid) {
  144. state.btnLoading = true;
  145. const url = state.ruleForm.id > 0 ? "investorInfo/modify" : "investorInfo/add"
  146. $body(url, state.ruleForm).then(() => {
  147. state.btnLoading = false;
  148. Msg.message('操作成功');
  149. console.log('submit!')
  150. onClose();
  151. emit('refresh');
  152. })
  153. } else {
  154. state.btnLoading = false;
  155. Msg.message('表单校验失败', 'error');
  156. }
  157. })
  158. };
  159. const handleFormChange = (formData: any) => {
  160. console.log(formData)
  161. }
  162. // 初始化表格数据
  163. const loadData = (id: any) => {
  164. $get(`investorInfo/detail/${id}`).then((res: any) => {
  165. state.ruleForm = res;
  166. })
  167. }
  168. // 暴露变量
  169. defineExpose({
  170. open
  171. });
  172. </script>