Browse Source

feat(bugs): 修改

tangning 3 years ago
parent
commit
54d99596a1
2 changed files with 190 additions and 4 deletions
  1. 173 0
      src/views/corporation/SetMealModal.vue
  2. 17 4
      src/views/corporation/index.vue

+ 173 - 0
src/views/corporation/SetMealModal.vue

@@ -0,0 +1,173 @@
+<template>
+  <BasicModal
+    v-bind="$attrs"
+    @register="register"
+    :title="t('routes.corporation.expirationTime')"
+    :minHeight="200"
+    @visible-change="handleVisibleChange"
+    @ok="handleSubmit"
+    @cancel="resetFields"
+  >
+    <div class="pt-2px pr-3px">
+      <BasicForm @register="registerForm" :model="model" />
+    </div>
+  </BasicModal>
+</template>
+<script lang="ts">
+  import { defineComponent, ref, nextTick } from 'vue';
+  import { BasicModal, useModalInner } from '/@/components/Modal';
+  import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
+  import { useMessage } from '/@/hooks/web/useMessage';
+  // import { checkUserAddAble } from '/@/api/corporation/modal';
+  import { useI18n } from '/@/hooks/web/useI18n';
+  import { updateCompnayApi } from '/@/api/corporation/list';
+  const { t } = useI18n();
+  export default defineComponent({
+    components: { BasicModal, BasicForm },
+    props: {
+      userData: { type: Object },
+    },
+    emits: ['register', 'submit'],
+    setup(props, { emit }) {
+      const modelRef = ref({
+        ifShow: true,
+      });
+      const { createMessage } = useMessage();
+      const schemas: FormSchema[] = [
+        {
+          field: 'id',
+          component: 'Input',
+          label: 'id',
+          show: false,
+        },
+        {
+          field: 'canShow',
+          component: 'RadioGroup',
+          label: '是否支持带逛',
+          required: true,
+          colProps: {
+            span: 22,
+          },
+          defaultValue: '0',
+          componentProps: {
+            options: [
+              {
+                label: '支持',
+                value: 1,
+              },
+              {
+                label: '不支持',
+                value: 0,
+              },
+            ],
+            onChange: (e) => {
+              console.log('data', e.target.value);
+              updateSchema({
+                field: 'liveRoomCapacities',
+                ifShow: e.target.value == 1 ? true : false,
+              });
+            },
+          },
+        },
+        {
+          field: 'liveRoomCapacities',
+          component: 'Select',
+          label: '套餐',
+          required: true,
+          colProps: {
+            span: 22,
+          },
+          ifShow: modelRef.value.ifShow,
+          componentProps: {
+            options: [
+              {
+                label: '1+29',
+                value: 30,
+              },
+              {
+                label: '1+39',
+                value: 40,
+              },
+              {
+                label: '1+49',
+                value: 50,
+              },
+              {
+                label: '1+99',
+                value: 100,
+              },
+            ],
+            onChange: (data, item) => {
+              console.log('data', data, item);
+            },
+          },
+        },
+      ];
+      const [
+        registerForm,
+        {
+          // getFieldsValue,
+          setFieldsValue,
+          // setProps
+          resetFields,
+          updateSchema,
+          validate,
+        },
+      ] = useForm({
+        labelWidth: 120,
+        schemas,
+        showActionButtonGroup: false,
+        actionColOptions: {
+          span: 24,
+        },
+      });
+      let addListFunc = () => {};
+      const [register, { closeModal }] = useModalInner((data) => {
+        console.log('insertData', data);
+        data && onDataReceive(data);
+      });
+
+      function onDataReceive(data) {
+        modelRef.value.ifShow = data.canShow == 1 ? true : false;
+        console.log('insertData', modelRef.value.ifShow);
+        setFieldsValue({ ...data });
+        updateSchema({
+          field: 'liveRoomCapacities',
+          ifShow: modelRef.value.ifShow,
+        });
+      }
+      const handleSubmit = async () => {
+        const values = await validate();
+        //TODO hack parameter
+        const res = await updateCompnayApi({
+          id: values.id,
+          expirationTime: values.expirationTime,
+        });
+        // let res = await checkUserAddAble({ phoneNum: values.managerPhone });
+        console.log('insertData', res);
+        emit('submit');
+        closeModal();
+        resetFields();
+        createMessage.success(t('common.optSuccess'));
+        // createMessage.success(t('routes.corporation.optSuccess'));
+      };
+      function handleVisibleChange(v) {
+        v && props.userData && nextTick(() => onDataReceive(props.userData));
+      }
+
+      return {
+        t,
+        register,
+        schemas,
+        registerForm,
+        model: modelRef,
+        handleVisibleChange,
+        handleSubmit,
+        addListFunc,
+        closeModal,
+        resetFields,
+        // nextTick,
+      };
+    },
+  });
+</script>

+ 17 - 4
src/views/corporation/index.vue

@@ -2,6 +2,11 @@
   <div class="p-4">
     <BasicTable @register="registerTable">
       <template #toolbar> </template>
+      <template #setMeal="{ record }">
+        <div style="color: #0960bd; cursor: pointer" @click="opensetMealModal(true, record)">{{
+          record.liveRoomCapacities
+        }}</div>
+      </template>
       <template #sceneLogo="{ record }">
         <CropperAvatar
           :showBtn="false"
@@ -98,23 +103,21 @@
     <SubaccountModal @register="registerSubaccountModal" @update="reload" />
     <cameraModal @register="registerCameraModal" @ok="reload" />
     <TimeModal @register="registerTimeModal" @submit="reload" />
+    <SetMealModal @register="registersetMealModal" @submit="reload" />
   </div>
 </template>
 <script lang="ts">
   import { useI18n } from '/@/hooks/web/useI18n';
   import { defineComponent, nextTick } from 'vue';
   import { BasicTable, useTable, BasicColumn, FormProps, TableAction } from '/@/components/Table';
-  // import { CollapseContainer } from '/@/components/Container';
   import { CropperAvatar } from '/@/components/Cropper';
   import { BasicUpload } from '/@/components/Upload';
-  // import { uploadApi } from '/@/api/sys/upload';
-  // import { Avatar } from 'ant-design-vue';
-  // import { getBasicColumns, getBasicData } from './tableData';
   import { ListApi, uploadLogoApi, updateCompnayApi } from '/@/api/corporation/list';
   import { useModal } from '/@/components/Modal';
   import chargeModal from './chargeModal.vue';
   import deviceModal from './deviceModal.vue';
   import TimeModal from './setTime.vue';
+  import SetMealModal from './SetMealModal.vue';
   import SubaccountModal from './SubaccountModal.vue';
   import cameraModal from './cameraModal.vue';
   import { Time } from '/@/components/Time';
@@ -134,6 +137,7 @@
       BasicUpload,
       Tag,
       TimeModal,
+      SetMealModal,
     },
     setup() {
       const [registerDeviceModal, { openModal: openDeviceModal }] = useModal();
@@ -141,6 +145,7 @@
       const [registerSubaccountModal, { openModal: openSubaccountModal }] = useModal();
       const [registerCameraModal, { openModal: openCameraModal }] = useModal();
       const [registerTimeModal, { openModal: openTimeModal }] = useModal();
+      const [registersetMealModal, { openModal: opensetMealModal }] = useModal();
       const { t } = useI18n();
       const columns: BasicColumn[] = [
         // {
@@ -197,6 +202,12 @@
           width: 80,
         },
         {
+          title: '带看套餐',
+          dataIndex: 'cameraNum',
+          slots: { customRender: 'setMeal' },
+          width: 80,
+        },
+        {
           title: t('routes.corporation.point'),
           ellipsis: false,
           dataIndex: 'point',
@@ -316,6 +327,7 @@
         registerChargeModal,
         registerDeviceModal,
         registerTimeModal,
+        registersetMealModal,
         registerSubaccountModal,
         handleOpenModal,
         uploadLogoApi: uploadLogoApi as any,
@@ -326,6 +338,7 @@
         registerCameraModal,
         openCameraModal,
         openTimeModal,
+        opensetMealModal,
       };
     },
   });