exportModal.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <BasicModal
  3. v-bind="$attrs"
  4. @register="register"
  5. title="查询并导出"
  6. @cancel="resetFields"
  7. :min-height="300"
  8. @ok="handleSubmit"
  9. >
  10. <div class="pt-2px pr-3px">
  11. <BasicForm @register="registerForm">
  12. <template #text="{ model, field }">
  13. {{ model[field] }}
  14. </template>
  15. </BasicForm>
  16. </div>
  17. </BasicModal>
  18. </template>
  19. <script lang="ts">
  20. import { defineComponent, ref, onMounted, reactive } from 'vue';
  21. import { BasicModal, useModalInner } from '/@/components/Modal';
  22. import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
  23. import { useMessage } from '/@/hooks/web/useMessage';
  24. import { useI18n } from '/@/hooks/web/useI18n';
  25. import { getinnerByRyId, userShareAdd } from '/@/api/operate';
  26. import { sceneGroupCount } from '/@/api/jyUserPlatform/index'; //roleLIstApi
  27. import { exportSceneList } from '/@/api/statistics/index'; //roleLIstApi
  28. import { district, jyType } from '/@/views/statistics/scene/data';
  29. const { t } = useI18n();
  30. export default defineComponent({
  31. components: { BasicModal, BasicForm },
  32. props: {
  33. userData: { type: Object },
  34. },
  35. emits: ['ok'],
  36. setup(_, { emit }) {
  37. const modelRef = ref(false);
  38. const fileFlow = reactive({
  39. file: null,
  40. });
  41. const { createMessage } = useMessage();
  42. const optionsName = ref([]);
  43. const schemas: FormSchema[] = [
  44. {
  45. field: 'platformId',
  46. component: 'Input',
  47. show: false,
  48. label: 'platformId',
  49. required: false,
  50. },
  51. {
  52. field: 'districtCodeList',
  53. component: 'ApiTreeSelect',
  54. label: '地区',
  55. componentProps: {
  56. treeData: district,
  57. listHeight: 200,
  58. multiple: true,
  59. treeNodeFilterProp: 'label',
  60. showSearch: true,
  61. },
  62. colProps: {
  63. span: 20,
  64. },
  65. },
  66. {
  67. field: 'jyType',
  68. component: 'Select',
  69. label: '警种',
  70. componentProps: {
  71. options: jyType,
  72. multiple: true,
  73. treeNodeFilterProp: 'label',
  74. showSearch: true,
  75. listHeight: 200,
  76. },
  77. colProps: {
  78. span: 20,
  79. },
  80. },
  81. {
  82. field: 'cameraTypeList',
  83. label: '相机类型',
  84. component: 'ApiSelect',
  85. componentProps: {
  86. style: { maxWidth: '297px' },
  87. placeholder: '全部',
  88. api: sceneGroupCount,
  89. multiple: true,
  90. immediate: false,
  91. resultField: 'list',
  92. labelField: 'name',
  93. valueField: 'id',
  94. params: { type: 'camera' },
  95. },
  96. },
  97. {
  98. field: 'timeList',
  99. component: 'RangePicker',
  100. label: '时间',
  101. componentProps: {
  102. valueFormat: 'YYYY-MM-DD',
  103. getCalendarContainer: (trigger) => trigger.parentNode,
  104. },
  105. colProps: {
  106. span: 20,
  107. },
  108. },
  109. ];
  110. const [
  111. registerForm,
  112. { validate, resetFields, setFieldsValue, getFieldsValue, updateSchema },
  113. ] = useForm({
  114. labelWidth: 110,
  115. schemas,
  116. showActionButtonGroup: false,
  117. actionColOptions: {
  118. span: 24,
  119. },
  120. });
  121. onMounted(() => {});
  122. let addListFunc = () => {};
  123. const [register, { closeModal }] = useModalInner(async (data) => {
  124. console.log('option', data);
  125. setFieldsValue({
  126. platformId: data.platformId,
  127. });
  128. updateSchema([
  129. {
  130. field: 'districtCodeList',
  131. componentProps: {
  132. treeData: data.district || [],
  133. disabled: data.district && data.district.length == 0,
  134. },
  135. },
  136. {
  137. field: 'jyType',
  138. componentProps: {
  139. options: data.jyType || [],
  140. disabled: data.jyType && data.jyType.length == 0,
  141. },
  142. },
  143. {
  144. field: 'ryNo',
  145. componentProps: {
  146. options: data.ryNo || [],
  147. onSearch: onSearch,
  148. filterOption: onFilterOption,
  149. },
  150. },
  151. ]);
  152. });
  153. function onFilterOption(inputText: string, option) {
  154. console.log('option', inputText, option.value);
  155. if (option.value) {
  156. return option.value.indexOf(inputText) >= 0;
  157. }
  158. // return option.value.indexOf(inputText.toUpperCase()) >= 0;
  159. }
  160. async function onSearch(searchText) {
  161. const res = await getinnerByRyId({ ryNo: searchText });
  162. console.log('res', res.data);
  163. if (!res.data) return;
  164. optionsName.value = res.data || {};
  165. updateSchema({
  166. field: 'ryNo',
  167. componentProps: {
  168. options: [optionsName.value],
  169. },
  170. });
  171. }
  172. const handleSubmit = async () => {
  173. const params = await validate();
  174. try {
  175. console.log('params', params);
  176. await exportSceneList(params);
  177. closeModal();
  178. resetFields();
  179. emit('ok');
  180. createMessage.success('操作成功');
  181. } catch (error) {
  182. console.log('not passing', error);
  183. }
  184. };
  185. return {
  186. register,
  187. schemas,
  188. registerForm,
  189. modelRef,
  190. fileFlow,
  191. handleSubmit,
  192. addListFunc,
  193. resetFields,
  194. t,
  195. };
  196. },
  197. });
  198. </script>