zhangjie 1 жил өмнө
parent
commit
c694344ca2

+ 12 - 6
src/components/common/select-filter-user/index.vue

@@ -17,12 +17,12 @@
 </template>
 
 <script setup name="SelectFilterUser">
-import { ref, watch } from 'vue';
+import { ref, watch, computed } from 'vue';
 import { getUserList } from '@/api/user';
 
 const emit = defineEmits(['update:modelValue', 'change']);
 const props = defineProps({
-  modelValue: { type: [Number, String], default: '' },
+  modelValue: { type: [Number, String, Array], default: '' },
   defaultList: {
     type: Array,
     default() {
@@ -30,6 +30,10 @@ const props = defineProps({
     },
   },
 });
+const isMultiple = computed(() => {
+  const multiple = attrs.multiple;
+  return multiple === '' || multiple;
+});
 
 let optionList = ref([]);
 let selected = ref('');
@@ -37,7 +41,7 @@ let loading = ref(false);
 
 async function search(userInfo) {
   if (!userInfo) {
-    optionList.value = defaultList;
+    optionList.value = props.defaultList;
     return;
   }
 
@@ -58,9 +62,11 @@ async function search(userInfo) {
 }
 
 const onChange = () => {
-  const selectedData = optionList.value.find(
-    (item) => selected.value === item.id
-  );
+  const selectedData = isMultiple.value
+    ? optionList.value.filter(
+        (item) => selected.value && selected.value.includes(item.id)
+      )
+    : optionList.value.filter((item) => selected.value === item.id);
   emit('update:modelValue', selected.value);
   emit('change', selectedData);
 };

+ 1 - 0
src/views/service-unit/service-unit-manage/range-manage/add-range-dialog.vue

@@ -74,6 +74,7 @@
   <mult-delineation-dialog
     v-model:visible="showMultDelineationDialog"
     :crm-ids="selectedRowKeys"
+    :customType="selectedRows[0]?.productType"
     dialog-title="保存划定"
     @success="search"
   >

+ 53 - 0
src/views/sop/components/metadata-content.vue

@@ -0,0 +1,53 @@
+<template>
+  <div v-if="IS_SIMPLE_TYPE">{{ value }}</div>
+  <div v-else-if="IS_OPTION_TYPE">
+    <p v-for="(cont, cindex) in optionValData" :key="cindex">{{ cont }}</p>
+  </div>
+  <div v-else-if="config.code === 'DATE'">{{ timestampFilter(value * 1) }}</div>
+  <div v-else>{{ value }}</div>
+</template>
+
+<script setup name="MetadataContent">
+import { timestampFilter } from '@/utils/filter';
+import { computed } from 'vue';
+
+const props = defineProps({
+  config: {
+    type: Object,
+    default() {
+      return { code: '' };
+    },
+  },
+  value: { type: [String, Number] },
+});
+
+const IS_SIMPLE_TYPE = computed(() => {
+  return ['NUMBER', 'TEXTAREA', 'TEXT'].includes(props.config.code);
+});
+const IS_OPTION_TYPE = computed(() => {
+  return ['SINGLE_SELECT', 'MULTIPLE_SELECT', 'RADIO', 'CHECKBOX'].includes(
+    props.config.code
+  );
+});
+const optionValData = computed(() => {
+  if (!IS_OPTION_TYPE.value || !props.config.options) return [props.value];
+  const options =
+    typeof props.config.options === 'string'
+      ? JSON.parse(props.config.options)
+      : props.config.options;
+  let optionDict = {};
+  options.forEach((item) => {
+    optionDict[item.value] = item.label;
+  });
+
+  const isMultiple = ['MULTIPLE_SELECT', 'CHECKBOX'].includes(
+    props.config.code
+  );
+  if (isMultiple) {
+    const vals = props.value ? JSON.parse(props.value) : [];
+    return vals.map((val) => optionDict[val]);
+  } else {
+    return [optionDict[props.value]];
+  }
+});
+</script>

+ 6 - 0
src/views/sop/components/select-filter/config.js

@@ -167,6 +167,12 @@ export const staticMetadata = [
   },
 ];
 
+export const specialUserMeta = [
+  'region_user_id_1',
+  'engineer_user_id_1',
+  'assistant_engineer_user_id_1',
+];
+
 export function getOperatorByCode(code) {
   return operatorConfig
     .filter((item) => item.range.includes(code))

+ 15 - 4
src/views/sop/components/select-filter/field-value.vue

@@ -1,6 +1,12 @@
 <template>
+  <select-filter-user
+    v-if="isSpecialUserMeta"
+    v-model="fieldVal"
+    multiple
+    @change="emitChange"
+  ></select-filter-user>
   <t-input-number
-    v-if="isNumber"
+    v-else-if="isNumber"
     v-model="fieldVal"
     theme="column"
     :decimalPlaces="0"
@@ -8,14 +14,14 @@
     @change="emitChange"
   ></t-input-number>
   <t-input
-    v-if="isInput"
+    v-else-if="isInput"
     v-model="fieldVal"
     placeholder="请输入"
     style="width: 100%"
     @change="emitChange"
   ></t-input>
   <t-select
-    v-if="isSelect"
+    v-else-if="isSelect"
     v-model="fieldVal"
     multiple
     :options="field.options || []"
@@ -24,7 +30,7 @@
     style="width: 100%"
     @change="emitChange"
   ></t-select>
-  <template v-if="isDate">
+  <template v-else-if="isDate">
     <t-date-range-picker
       v-if="field.operator === 'RANGE'"
       v-model="fieldVal"
@@ -44,6 +50,7 @@
 
 <script setup lang="jsx" name="FieldValue">
 import { ref, computed, watch } from 'vue';
+import { specialUserMeta } from './config';
 
 const emit = defineEmits(['update:modelValue', 'change']);
 const props = defineProps({
@@ -52,6 +59,7 @@ const props = defineProps({
     type: Object,
     default() {
       return {
+        fieldId: '',
         code: '',
         operator: '',
         options: [],
@@ -61,6 +69,9 @@ const props = defineProps({
 });
 let fieldVal = ref(null);
 
+const isSpecialUserMeta = computed(() => {
+  return specialUserMeta.includes(props.field.fieldId);
+});
 const isNumber = computed(() => {
   return ['NUMBER'].includes(props.field.code);
 });

+ 3 - 1
src/views/sop/components/select-metadata.vue

@@ -58,7 +58,9 @@ const search = async () => {
   optionList.value = [];
   const res = await metadataListApi({ type: props.type }).catch(() => {});
   if (!res) return;
-  optionList.value = res;
+  const noneedCodes = ['FILE', 'TABLE', 'DEVICE_OUT_TABLE', 'DEVICE_IN_TABLE'];
+  optionList.value = res.filter((item) => !noneedCodes.includes(item.code));
+  // console.log(new Set(optionList.value.map((item) => item.code)));
 };
 onMounted(() => {
   search();

+ 18 - 1
src/views/sop/sop-manage/office-sop/index.vue

@@ -91,6 +91,20 @@
         <template #flowUpdateTime="{ col, row }">
           {{ timestampFilter(row[col.colKey]) }}
         </template>
+        <template
+          v-for="field in formWidgetMetadataViewList"
+          #[field.fieldId]="{ col, row }"
+        >
+          <metadata-content
+            :value="row[col.colKey]"
+            :config="{
+              code: col.colKeyCode,
+              fieldId: col.colKey,
+              options: col.colOptions,
+            }"
+          ></metadata-content>
+        </template>
+
         <template #operate="{ row }">
           <div class="table-operations">
             <template v-if="perm.LINK_Fill">
@@ -200,6 +214,7 @@ import SopStepDialog from '../sop-step/sop-step-dialog.vue';
 import QualityIssueDialog from '../quality-issue/quality-issue-dialog.vue';
 import PlanChangeDialog from '../plan-change/plan-change-dialog.vue';
 import AddViolationDialog from '../../sop-monitor/violation-registration/add-violation-dialog.vue';
+import MetadataContent from '../../components/metadata-content.vue';
 import { useAppStore } from '@/store';
 import usePermission from '@/hooks/usePermission';
 const { perm } = usePermission();
@@ -249,7 +264,9 @@ const columns = computed(() => {
       return {
         colKey: item.fieldId,
         title: item.fieldTitle,
-        minWidth: 120,
+        colOptions: item.options,
+        colKeyCode: item.code,
+        minWidth: 170,
       };
     });
     return [

+ 17 - 1
src/views/sop/sop-manage/student-sop/index.vue

@@ -91,6 +91,19 @@
         <template #flowUpdateTime="{ col, row }">
           {{ timestampFilter(row[col.colKey]) }}
         </template>
+        <template
+          v-for="field in formWidgetMetadataViewList"
+          #[field.fieldId]="{ col, row }"
+        >
+          <metadata-content
+            :value="row[col.colKey]"
+            :config="{
+              code: col.colKeyCode,
+              fieldId: col.colKey,
+              options: col.colOptions,
+            }"
+          ></metadata-content>
+        </template>
         <template #operate="{ row }">
           <div class="table-operations" @click.stop>
             <template v-if="perm.LINK_Fill">
@@ -200,6 +213,7 @@ import SopStepDialog from '../sop-step/sop-step-dialog.vue';
 import QualityIssueDialog from '../quality-issue/quality-issue-dialog.vue';
 import PlanChangeDialog from '../plan-change/plan-change-dialog.vue';
 import AddViolationDialog from '../../sop-monitor/violation-registration/add-violation-dialog.vue';
+import MetadataContent from '../../components/metadata-content.vue';
 import { useAppStore } from '@/store';
 import usePermission from '@/hooks/usePermission';
 const { perm } = usePermission();
@@ -248,7 +262,9 @@ const columns = computed(() => {
       return {
         colKey: item.fieldId,
         title: item.fieldTitle,
-        minWidth: 120,
+        colOptions: item.options,
+        colKeyCode: item.code,
+        minWidth: 170,
       };
     });
     return [

+ 18 - 10
src/views/system/task/task-manage/index.vue

@@ -1,6 +1,14 @@
 <template>
   <div class="flex flex-col h-full">
-    <SearchForm :fields="fields" :params="params"></SearchForm>
+    <SearchForm :fields="fields" :params="params">
+      <template #type="{ item, params }">
+        <t-select
+          v-model="params[item.prop]"
+          :options="taskTypeList"
+          clearable
+        ></t-select>
+      </template>
+    </SearchForm>
     <div class="flex-1 page-wrap">
       <t-table
         size="small"
@@ -68,13 +76,10 @@ import useFetchTable from '@/hooks/useFetchTable';
 import { taskQueryApi } from '@/api/system';
 import { getAttachmentFile } from '@/api/user';
 import { dictToOptionList, downloadByUrl } from '@/utils/tool';
-import {
-  DATA_TASK_STATUS,
-  DATA_TASK_RESULT,
-  DATA_TASK_TYPE,
-} from '@/config/constants';
+import { DATA_TASK_STATUS, DATA_TASK_RESULT } from '@/config/constants';
 import { timestampFilter } from '@/utils/filter';
 import usePermission from '@/hooks/usePermission';
+import { enumListByType } from '@/api/common';
 const { perm } = usePermission();
 
 const fields = ref([
@@ -84,10 +89,6 @@ const fields = ref([
     type: 'select',
     labelWidth: 100,
     colSpan: 5,
-    options: dictToOptionList(DATA_TASK_TYPE),
-    attrs: {
-      clearable: true,
-    },
   },
   {
     prop: 'status',
@@ -154,6 +155,13 @@ const {
   params,
 });
 
+const taskTypeList = ref([]);
+async function getTaskTypeList() {
+  const res = await enumListByType('TASK_TYPE_ENUM');
+  taskTypeList.value = dictToOptionList(res || {});
+}
+getTaskTypeList();
+
 async function handleDownload(row, type) {
   const res = await getAttachmentFile(row.id, type).catch(() => {});
   if (!res) return;