| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <template>
- <BasicModal
- v-bind="$attrs"
- @register="register"
- title="查询并导出"
- @cancel="resetFields"
- :min-height="300"
- @ok="handleSubmit"
- >
- <div class="pt-2px pr-3px">
- <BasicForm @register="registerForm">
- <template #text="{ model, field }">
- {{ model[field] }}
- </template>
- </BasicForm>
- </div>
- </BasicModal>
- </template>
- <script lang="ts">
- import { defineComponent, ref, onMounted, reactive } from 'vue';
- import { BasicModal, useModalInner } from '/@/components/Modal';
- import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
- import { useMessage } from '/@/hooks/web/useMessage';
- import { useI18n } from '/@/hooks/web/useI18n';
- import { getinnerByRyId, userShareAdd } from '/@/api/operate';
- import { sceneGroupCount } from '/@/api/jyUserPlatform/index'; //roleLIstApi
- import { exportSceneList } from '/@/api/statistics/index'; //roleLIstApi
- import { district, jyType } from '/@/views/statistics/scene/data';
- const { t } = useI18n();
- export default defineComponent({
- components: { BasicModal, BasicForm },
- props: {
- userData: { type: Object },
- },
- emits: ['ok'],
- setup(_, { emit }) {
- const modelRef = ref(false);
- const fileFlow = reactive({
- file: null,
- });
- const { createMessage } = useMessage();
- const optionsName = ref([]);
- const schemas: FormSchema[] = [
- {
- field: 'platformId',
- component: 'Input',
- show: false,
- label: 'platformId',
- required: false,
- },
- {
- field: 'districtCodeList',
- component: 'ApiTreeSelect',
- label: '地区',
- componentProps: {
- treeData: district,
- listHeight: 200,
- multiple: true,
- treeNodeFilterProp: 'label',
- showSearch: true,
- },
- colProps: {
- span: 20,
- },
- },
- {
- field: 'jyType',
- component: 'Select',
- label: '警种',
- componentProps: {
- options: jyType,
- multiple: true,
- treeNodeFilterProp: 'label',
- showSearch: true,
- listHeight: 200,
- },
- colProps: {
- span: 20,
- },
- },
- {
- field: 'cameraTypeList',
- label: '相机类型',
- component: 'ApiSelect',
- componentProps: {
- style: { maxWidth: '297px' },
- placeholder: '全部',
- api: sceneGroupCount,
- multiple: true,
- immediate: false,
- resultField: 'list',
- labelField: 'name',
- valueField: 'id',
- params: { type: 'camera' },
- },
- },
- {
- field: 'timeList',
- component: 'RangePicker',
- label: '时间',
- componentProps: {
- valueFormat: 'YYYY-MM-DD',
- getCalendarContainer: (trigger) => trigger.parentNode,
- },
- colProps: {
- span: 20,
- },
- },
- ];
- const [
- registerForm,
- { validate, resetFields, setFieldsValue, getFieldsValue, updateSchema },
- ] = useForm({
- labelWidth: 110,
- schemas,
- showActionButtonGroup: false,
- actionColOptions: {
- span: 24,
- },
- });
- onMounted(() => {});
- let addListFunc = () => {};
- const [register, { closeModal }] = useModalInner(async (data) => {
- console.log('option', data);
- setFieldsValue({
- platformId: data.platformId,
- });
- updateSchema([
- {
- field: 'districtCodeList',
- componentProps: {
- treeData: data.district || [],
- disabled: data.district && data.district.length == 0,
- },
- },
- {
- field: 'jyType',
- componentProps: {
- options: data.jyType || [],
- disabled: data.jyType && data.jyType.length == 0,
- },
- },
- {
- field: 'ryNo',
- componentProps: {
- options: data.ryNo || [],
- onSearch: onSearch,
- filterOption: onFilterOption,
- },
- },
- ]);
- });
- function onFilterOption(inputText: string, option) {
- console.log('option', inputText, option.value);
- if (option.value) {
- return option.value.indexOf(inputText) >= 0;
- }
- // return option.value.indexOf(inputText.toUpperCase()) >= 0;
- }
- async function onSearch(searchText) {
- const res = await getinnerByRyId({ ryNo: searchText });
- console.log('res', res.data);
- if (!res.data) return;
- optionsName.value = res.data || {};
- updateSchema({
- field: 'ryNo',
- componentProps: {
- options: [optionsName.value],
- },
- });
- }
- const handleSubmit = async () => {
- const params = await validate();
- try {
- console.log('params', params);
- await exportSceneList(params);
- closeModal();
- resetFields();
- emit('ok');
- createMessage.success('操作成功');
- } catch (error) {
- console.log('not passing', error);
- }
- };
- return {
- register,
- schemas,
- registerForm,
- modelRef,
- fileFlow,
- handleSubmit,
- addListFunc,
- resetFields,
- t,
- };
- },
- });
- </script>
|