productSpaceEdit.vue 11.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
<template>
  <div class="container_wrap full" v-loading="fullscreenLoading">
    <div class="content_main">
      <ContentWrap id="id-baseInfo" title="逻辑空间信息" description="" :isExpand="baseInfoExpand" :expand-swicth="true"
        class="mb16" @expand="(v) => baseInfoExpand = v">
        <Form ref="baseInfoFormRef" :itemList="baseInfoFormItems" formId="base-info-form" :rules="baseInfoFormRules"
          col="col3" />
        <el-tabs v-model="activeTabName" class="param-tabs">
          <el-tab-pane label="成员权限" name="member">
            <Table ref="memberTableRef" :tableInfo="memberTableInfo" class="fiveRow-table" />
            <div class="row-add-btn">
              <el-button link @click="addMember" :icon="CirclePlus" v-preReClick>添加</el-button>
            </div>
          </el-tab-pane>
          <el-tab-pane label="策略配置" name="strategy">
            <StrategyTable ref="strategyTableRef" :value="detailInfo.policyRSVOS || (route.query.guid ? [] : [{
              index: 1,
              action: '',
              children: [{ childIndex: 1 }]
            }])" :operatorOptionList="operatorOptionList" :actionOptionsList="actionOptionsList"
              :constraintOptionsList="constraintOptionsList"></StrategyTable>
          </el-tab-pane>
        </el-tabs>
      </ContentWrap>
      <ContentWrap id="id-approveInfo" title="流程审批" expandSwicth style="margin-top: 15px" :isExpand="expandApprove"
        @expand="(v) => expandApprove = v">
        <ApprovalProcess ref="approvalProcessRef" v-if="deploymentId" :deploymentId="deploymentId"
          :processInstanceId="processInstanceId">
        </ApprovalProcess>
      </ContentWrap>
    </div>
    <div class="bottom_tool_wrap">
      <el-button @click="cancel">取消</el-button>
      <el-button @click="save" v-preReClick>保存</el-button>
      <el-button type="primary" @click="submit" v-preReClick>提交审批</el-button>
    </div>
  </div>
</template>

<script lang="ts" setup name="productSpaceEdit">
import { CirclePlus } from "@element-plus/icons-vue";
import { getCamundaDeploymentId } from "@/api/modules/workFlowService";
import {
  getParamsList
} from "@/api/modules/queryService";
import {
  getActionPolicyList,
  getConstraintPolicyList,
} from "@/api/modules/dataSmartContract"
import useUserStore from "@/store/modules/user";
import useDataProductApplicationStore from "@/store/modules/productApplication";
import { useValidator } from '@/hooks/useValidator';
import { TableColumnWidth } from "@/utils/enum";
import { scrollLastRowToView } from "@/utils/common";
import StrategyTable from "../data_smart_contract/components/strategyTable.vue";

const { required } = useValidator();

const { proxy } = getCurrentInstance() as any;

const userStore = useUserStore();
const productApplicationStore = useDataProductApplicationStore();
const route = useRoute();
const router = useRouter();
const userData = JSON.parse(localStorage.userData);
const fullPath = route.fullPath;

const detailInfo: any = ref({});

const fullscreenLoading = ref(false);
const baseInfoExpand = ref(true);
const expandApprove = ref(true);

/** 约束运算符字典下拉 */
const operatorOptionList: any = ref([]);

/** 约束行为下拉列表 */
const constraintOptionsList: any = ref([]);

/** 策略操作行为下拉列表 */
const actionOptionsList: any = ref([]);

/** 页签当前活跃的有成员权限和策略配置 */
const activeTabName = ref('member');

const deploymentId = ref('');
const processInstanceId = ref('');

const baseInfoFormRef = ref();

const domainDictList: any = ref([]);

const baseInfoFormItems = ref([
  {
    label: '逻辑空间名称',
    type: 'input',
    placeholder: '请输入',
    field: 'spaceName',
    maxlength: 50,
    default: '',
    clearable: true,
    required: true
  },
  {
    label: '所属领域',
    type: 'select',
    placeholder: '请选择',
    field: 'domain',
    default: '003',
    options: domainDictList.value,
    props: {
      value: 'value',
      label: 'label',
      children: 'children'
    },
    required: true,
    filterable: true,
    clearable: true,
    visible: true
  },
  {
    label: '创建企业',
    type: 'input',
    placeholder: '请输入',
    field: 'tenantName',
    default: userData.tenantName,
    required: true,
    disabled: true
  },
  {
    label: '是否开启',
    type: 'switch',
    field: 'bizState',
    default: 'Y',
    placeholder: '请选择',
    activeValue: 'Y',
    inactiveValue: 'S',
    required: true,
    switchWidth: 32,
  },
  {
    label: '逻辑空间描述',
    type: 'textarea',
    placeholder: '该逻辑空间主要为医疗机构的数据产品,限制了数据产品以及只有进行查看操作。参与方为某某医药企业、某某医疗机构以及运营方。',
    field: 'description',
    default: '',
    block: true,
    maxlength: 500,
    clearable: true,
    required: true,
  },
])

const baseInfoFormRules = ref({
  spaceName: [required('请输入逻辑空间名称')],
  domain: [required('请选择所属领域')],
  description: [required('请输入逻辑空间描述')]
})

const cancel = () => {
  proxy.$openMessageBox("当前页面尚未保存,确定放弃修改吗?", () => {
    userStore.setTabbar(userStore.tabbar.filter((tab: any) => tab.fullPath !== fullPath));
    router.push({
      name: 'productSpaceManage'
    });
  }, () => {
    proxy.$ElMessage.info("已取消");
  });
}

const memberTenantList: any = ref([]);

const roleTypeList: any = ref([{
  value: 'use',
  label: '数据使用方'
}, {
  value: 'provider',
  label: '数据提供方'
}]);

/** 对表格组件的引用 */
const memberTableRef = ref();

/** 成员权限表格 */
const memberTableData: any = ref([]);

/** 成员权限表格 */
const memberTableInfo = ref({
  id: "input-params-table",
  height: '214px',
  fields: [
    { label: "序号", type: "index", width: TableColumnWidth.INDEX, align: "center" },
    { label: "成员名称", field: "memberGuid", width: 200, required: true, columClass: 'edit-colum', type: 'edit' },
    { label: "角色类型", field: "roleType", width: 160, required: true, columClass: 'edit-colum', type: 'edit' },
    { label: "描述", field: "description", width: 300, required: false, columClass: 'edit-colum', type: 'edit' },
  ],
  editInfo: {
    memberGuid: {
      label: '',
      type: 'select',
      field: 'memberGuid',
      default: '',
      options: memberTenantList.value,
      props: {
        label: 'tenantName',
        value: 'guid'
      },
      placeholder: '请选择',
      clearable: true,
      filterable: true
    },
    roleType: {
      label: '',
      type: 'select',
      field: 'roleType',
      default: '',
      options: roleTypeList.value,
      props: {
        label: 'label',
        value: 'value'
      },
      placeholder: '请选择',
      clearable: true,
      filterable: true
    },
    description: {
      label: '',
      type: 'input',
      field: 'description',
      default: '',
      maxlength: 200,
      placeholder: '请输入',
      clearable: true,
    }
  },
  STATUS: 'edit',
  data: memberTableData.value,
  showPage: false,
  actionInfo: {
    show: true,
    label: "操作",
    type: "btn",
    width: 60,
    fixed: 'right',
    btns: [
      {
        label: "删除", value: "remove", click: (scope) => {
          let index = scope.$index;
          proxy.$openMessageBox("此操作将永久删除, 是否继续?", () => {
            memberTableData.value.splice(index, 1);
            memberTableInfo.value.data = memberTableData.value;
            proxy.$ElMessage.success('参数删除成功');
          }, () => {
            proxy.$ElMessage.info("已取消");
          });
        }
      },
    ]
  },
  loading: false
});

/** 给表格添加一行入参定义。 */
const addMember = () => {
  memberTableData.value.push({ memberGuid: '', roleType: '', description: '' });
  memberTableInfo.value.data = memberTableData.value;
  nextTick(() => {
    scrollLastRowToView(memberTableRef.value?.tableRef, memberTableData.value.length);
  })
}

const save = () => {
  // 保存不检验。
}

const submit = () => {
  baseInfoFormRef.value?.ruleFormRef?.validate().then((valid, errorItem) => {
    if (valid) {
      let formInline = baseInfoFormRef.value.formInline;
      //  fullscreenLoading.value = true;
      //  listingSavePortal(params).then((res: any) => {
      //   fullscreenLoading.value = false;
      //     if (res?.code == proxy.$passCode) {
      //       proxy.$ElMessage.success('提交审批成功');
      //       userStore.setTabbar(userStore.tabbar.filter((tab: any) => tab.fullPath !== fullPath));
      //       productApplicationStore.setIsRefresh(true);
      //       router.push({
      //         name: "productApplicationManage",
      //       });
      //     } else {
      //       res?.msg && proxy.$ElMessage.error(res.msg);
      //     }
      //   }).catch((res) => {
      //     fullscreenLoading.value = false;
      //   });
    } else {
      var obj = Object.keys(errorItem);
      baseInfoFormRef.value.ruleFormRef.scrollToField(obj[0]);
    }
  })
}

onActivated(() => {
  let tab: any = userStore.tabbar.find((tab: any) => tab.fullPath == fullPath);
  let detailType = route.query.type;
  let name = route.query.name;
  if (tab) {
    switch (detailType) {
      case 'edit':
        tab.meta.title = `编辑-${name}`;
        break;
      case 'redit':
        tab.meta.title = `编辑-${name}`;
        break;
      default:
        tab.meta.title = '新增逻辑空间';
    }
    document.title = tab.meta.title;
  };
})

onBeforeMount(() => {
  // getCamundaDeploymentId('10016', userData.tenantGuid, userData.staffGuid).then((res: any) => {
  //   if (res.code == proxy.$passCode) {
  //     deploymentId.value = res.data;
  //   } else {
  //     proxy.$ElMessage.error(res.msg);
  //   }
  // })

  getParamsList({ dictType: '领域' }).then((res: any) => {
    if (res.code == proxy.$passCode) {
      domainDictList.value = res.data || [];
      let itemIndex = baseInfoFormItems.value.findIndex(item => item.field == 'domain');
      let item = baseInfoFormItems.value[itemIndex];
      item && (item.options = domainDictList.value);
    } else {
      proxy.$ElMessage.error(res.msg);
    }
  });

  getParamsList({ dictType: '约束运算符' }).then((res: any) => {
    if (res?.code == proxy.$passCode) {
      const data = res.data || [];
      operatorOptionList.value = data;
    } else {
      res?.msg && proxy.$ElMessage.error(res?.msg);
    }
  })
  getActionPolicyList().then((res: any) => {
    if (res?.code == proxy.$passCode) {
      const data = res.data || [];
      actionOptionsList.value = data;
    } else {
      res?.msg && proxy.$ElMessage.error(res?.msg);
    }
  })
  getConstraintPolicyList().then((res: any) => {
    if (res?.code == proxy.$passCode) {
      const data = res.data || [];
      constraintOptionsList.value = data;
    } else {
      res?.msg && proxy.$ElMessage.error(res?.msg);
    }
  })
})

</script>

<style lang="scss" scoped>
.content_main {
  height: calc(100% - 40px);
  padding: 16px;
  overflow: hidden auto;
  position: sticky;
}

.bottom_tool_wrap {
  height: 40px;
  padding: 0 16px;
  border-top: 1px solid #d9d9d9;
  display: flex;
  justify-content: center;
  align-items: center;
}

.row-add-btn {
  .el-button--default {
    padding: 4px 0px;
    margin-top: 4px;
  }

  :deep(.el-icon) {
    width: 16px;
    height: 16px;

    svg {
      width: 16px;
      height: 16px;
    }
  }
}

:deep(.el-tabs) {
  margin-top: -8px;

  .el-tabs__header {
    margin-bottom: 8px;
  }

  .el-tabs__item {
    height: 32px;

    &:nth-child(2) {
      padding-left: 16px;
    }

  }
}
</style>