confirmDialog.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <van-popup v-model:show="visible">
  3. <van-form @submit="on_submit">
  4. <div class="van-doc-block__title">{{ title }}</div>
  5. <van-cell-group inset>
  6. <van-field
  7. required
  8. v-model="form.content"
  9. placeholder="请填写审批内容"
  10. :rules="[{ required: true, message: '请填写审批内容' }]"
  11. rows="3"
  12. autosize
  13. type="textarea"
  14. maxlength="150"
  15. show-word-limit
  16. />
  17. </van-cell-group>
  18. <div style="margin: 3.0vmin;display: flex;
  19. flex-direction: row;
  20. justify-content: flex-end;">
  21. <div style="display: flex; flex-direction: row; justify-content: space-between;">
  22. <van-button @click="closeDialog(false)" style="margin-right:10px;">取 消</van-button>
  23. <van-button type="primary" native-type="submit">提 交</van-button>
  24. </div>
  25. </div>
  26. </van-form>
  27. </van-popup>
  28. </template>
  29. <script lang="ts" setup>
  30. import { WorkApprovalConfirm } from "@/api/InformationReception/InformationReception";
  31. import { showSuccessToast } from 'vant';
  32. const proxy = getCurrentInstance()?.proxy;
  33. const title = ref('');
  34. interface Form {
  35. info_id: string;
  36. content: string;
  37. examine_type: string;
  38. }
  39. interface Props {
  40. modelValue: boolean;
  41. data: Form;
  42. }
  43. const form = ref<Form>({
  44. info_id: "",
  45. content: "",
  46. examine_type: ""
  47. });
  48. const props = withDefaults(defineProps<Props>(), {
  49. modelValue: false
  50. });
  51. const emits = defineEmits(['update:modelValue']);
  52. watch(
  53. () => props.modelValue,
  54. () => {
  55. if (props.modelValue) {
  56. form.value = props.data;
  57. title.value = form.value.examine_type == 'approved' ? "审批通过": "审批不通过";
  58. }
  59. visible.value = props.modelValue;
  60. }
  61. );
  62. const visible = ref(false);
  63. const on_submit = () => {
  64. console.log('on_submit');
  65. WorkApprovalConfirm(form.value).then((res) => {
  66. showSuccessToast(res.msg);
  67. closeDialog(true)
  68. }).catch((err) => {
  69. });
  70. };
  71. const closeDialog = (t) => {
  72. emits('update:modelValue', t);
  73. };
  74. </script>
  75. <style lang="scss" scoped>
  76. .van-doc-block__title {
  77. color: var(--van-doc-text-color-4);
  78. margin: 0px;
  79. padding: 3vmin;
  80. font-size: 4.6vmin;
  81. font-weight: 600;
  82. line-height: 6.0vmin;
  83. }
  84. </style>