FlowEditBoSetting.vue 33.9 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 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076
<template>
  <div style="height: calc(100% - 48px); margin: 24px">
    <el-card class="bo-set__card" shadow="never">
      <div slot="header" class="flex" style="justify-content: space-between">
        <div style="display:flex">
          <ht-select
            size="mini"
            clearable
            v-model="selectedNode"
            :options="nodeOptions"
            :props="{key: 'nodeId', value: 'label'}"
          />
          <el-button
            size="mini"
            style="margin-left: 10px"
            icon="el-icon-plus"
            type="primary"
            @click="editNodeSet('')"
            >添加</el-button
          >
        </div>
        <div
          class="flex top-button"
          style="width: 125px; justify-content: space-between"
        >
          <el-button size="mini" type="primary" @click="save(false)"
            >保存</el-button
          >
          <el-button size="mini" type="primary" plain @click="reset"
            >重置</el-button
          >
        </div>
      </div>
      <el-scrollbar class="scrollbar-fullheight">
        <div v-for="(value, key) in nodeSetMap" :key="key">
          <div class="scrollbar-title">{{ getDesc(key) }}</div>
          <table
            class="form-table bo-set__table"
            cellspacing="0"
            cellpadding="0"
            border="0"
          >
            <tbody>
              <tr>
                <td>
                  <el-table class="bo-set__detail" :data="value" border>
                    <el-table-column
                      type="index"
                      width="60"
                      label="序号"
                      align="center"
                    ></el-table-column>
                    <el-table-column
                      prop="description"
                      label="描述"
                      align="center"
                    />
                    <el-table-column label="操作" width="160" align="center">
                      <template v-slot="{row, $index}">
                        <el-button
                          size="mini"
                          type="text"
                          @click="editNodeSet(key, $index, row)"
                          >编辑</el-button
                        >
                        <el-button
                          type="text"
                          size="mini"
                          @click="deleteSetting(value, $index)"
                        >
                          删除</el-button
                        >
                      </template>
                    </el-table-column>
                  </el-table>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </el-scrollbar>
    </el-card>

    <el-dialog
      top="8vh"
      width="60%"
      title="Bo任务节点设置"
      :visible.sync="dialogVisibleSetting"
      append-to-body
      class="urgent-text"
      :close-on-click-modal="false"
    >
      <div style="width: 100%; height: 550px">
        <div style="float: left; width: 25%; height: 95%">
          <ht-tree
            style="
              overflow: auto;
              height: 100%;
              border: 1px solid #ebebeb;
              margin-bottom: 5%;
            "
            :data="treeData"
            :props="defaultProps"
            default-expand-all
            @node-click="handleNodeClick"
            :expand-on-click-node="false"
            class="htTypeTree"
            ref="htTypeTree"
          ></ht-tree>
        </div>
        <div
          style="
            width: calc(75% - 35px);
            float: left;
            margin-left: 32px;
            height: 95%;
            margin-bottom: 5%;
          "
        >
          <table class="form-table" cellspacing="0" cellpadding="0" border="0">
            <tbody>
              <tr style="border: 1px solid #ebebeb">
                <th width="110px" class="is-required table_lable">描述:</th>
                <td>
                  <ht-input
                    v-model="dataDialog.description"
                    placeholder="请输入描述"
                    autocomplete="off"
                    :validate="{required: true}"
                  ></ht-input>
                </td>
              </tr>
            </tbody>
          </table>
          <el-tabs
            v-model="tabType"
            type="border-card"
            style="height: calc(100% - 67px)"
          >
            <el-tab-pane label="显示前" name="beforeShow">
              <el-form v-model="dataDialog" data-vv-scope="settingSave">
                <table
                  class="form-table"
                  cellspacing="0"
                  cellpadding="0"
                  border="0"
                >
                  <tbody>
                    <tr>
                      <th
                        width="100px"
                        style="
                          padding: 24px 0 10px 10px;
                          display: flex;
                          justify-content: center;
                        "
                      >
                        脚本内容:
                      </th>
                      <td>
                        <!-- 常用脚本选择对话框  -->
                        <eip-script-dialog
                          ref="beforeShowDialog"
                          v-model="dataDialog.beforeShow"
                          append-to-body
                        />
                        <el-button
                          class="often-button"
                          @click="showDialog('beforeShowDialog')"
                          >常用脚本
                        </el-button>
                        <!-- 可选变量对话框 -->
                        <FlowVarSelector
                          :defId="defId"
                          @node-click="varTreeConfirm($event, 'beforeShow')"
                        />
                        <br />
                        <br />
                        <ht-input
                          type="textarea"
                          :rows="14"
                          class="ht"
                          v-model="dataDialog.beforeShow"
                          placeholder="请输入脚本内容"
                          autocomplete="off"
                        ></ht-input>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </el-form>
            </el-tab-pane>
            <el-tab-pane label="保存时" name="whenSave">
              <el-form v-model="dataDialog" data-vv-scope="settingSave">
                <table
                  class="form-table"
                  cellspacing="0"
                  cellpadding="0"
                  border="0"
                >
                  <tbody>
                    <tr>
                      <th width="100px">脚本内容:</th>
                      <td>
                        <!-- 常用脚本选择对话框  -->
                        <eip-script-dialog
                          ref="whenSaveDialog"
                          v-model="dataDialog.whenSave"
                          append-to-body
                        />
                        <el-button @click="showDialog('whenSaveDialog')"
                          >常用脚本</el-button
                        >
                        <!-- 可选变量对话框 -->
                        <FlowVarSelector
                          :defId="defId"
                          @node-click="varTreeConfirm($event, 'whenSave')"
                        />
                        <br />
                        <br />
                        <ht-input
                          type="textarea"
                          :rows="14"
                          class="ht"
                          v-model="dataDialog.whenSave"
                          placeholder="请输入脚本内容"
                          autocomplete="off"
                        ></ht-input>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </el-form>
            </el-tab-pane>
            <el-tab-pane label="同意时" name="whenAgree">
              <el-form v-model="dataDialog" data-vv-scope="whenAgree">
                <table
                  class="form-table"
                  cellspacing="0"
                  cellpadding="0"
                  border="0"
                >
                  <tbody>
                    <tr>
                      <th width="100px">脚本内容:</th>
                      <td>
                        <!-- 常用脚本选择对话框  -->
                        <eip-script-dialog
                          ref="whenAgree"
                          v-model="dataDialog.whenAgree"
                          append-to-body
                        />
                        <el-button @click="showDialog('whenAgree')"
                          >常用脚本</el-button
                        >
                        <!-- 可选变量对话框 -->
                        <flow-var-selector
                          :defId="defId"
                          @node-click="varTreeConfirm($event, 'whenAgree')"
                        />
                        <br />
                        <br />
                        <ht-input
                          type="textarea"
                          :rows="14"
                          class="ht"
                          v-model="dataDialog.whenAgree"
                          placeholder="请输入脚本内容"
                          autocomplete="off"
                        ></ht-input>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </el-form>
            </el-tab-pane>
            <el-tab-pane label="驳回时" name="whenReject">
              <el-form v-model="dataDialog" data-vv-scope="whenReject">
                <table
                  class="form-table"
                  cellspacing="0"
                  cellpadding="0"
                  border="0"
                >
                  <tbody>
                    <tr>
                      <th width="100px">脚本内容:</th>
                      <td>
                        <!-- 常用脚本选择对话框  -->
                        <eip-script-dialog
                          ref="whenReject"
                          v-model="dataDialog.whenReject"
                          append-to-body
                        />
                        <el-button @click="showDialog('whenReject')"
                          >常用脚本</el-button
                        >
                        <!-- 可选变量对话框 -->
                        <flow-var-selector
                          :defId="defId"
                          @node-click="varTreeConfirm($event, 'whenReject')"
                        />
                        <br />
                        <br />
                        <ht-input
                          type="textarea"
                          :rows="14"
                          class="ht"
                          v-model="dataDialog.whenReject"
                          placeholder="请输入脚本内容"
                          autocomplete="off"
                        ></ht-input>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </el-form>
            </el-tab-pane>
            <el-tab-pane label="反对时" name="whenOppose">
              <el-form v-model="dataDialog" data-vv-scope="whenOppose">
                <table
                  class="form-table"
                  cellspacing="0"
                  cellpadding="0"
                  border="0"
                >
                  <tbody>
                    <tr>
                      <th width="100px">脚本内容:</th>
                      <td>
                        <!-- 常用脚本选择对话框  -->
                        <eip-script-dialog
                          ref="whenOppose"
                          v-model="dataDialog.whenOppose"
                          append-to-body
                        />
                        <el-button @click="showDialog('whenOppose')"
                          >常用脚本</el-button
                        >
                        <!-- 可选变量对话框 -->
                        <flow-var-selector
                          :defId="defId"
                          @node-click="varTreeConfirm($event, 'whenOppose')"
                        />
                        <br />
                        <br />
                        <ht-input
                          type="textarea"
                          :rows="14"
                          class="ht"
                          v-model="dataDialog.whenOppose"
                          placeholder="请输入脚本内容"
                          autocomplete="off"
                        ></ht-input>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </el-form>
            </el-tab-pane>
            <el-tab-pane label="征询时" name="whenConsult">
              <el-form v-model="dataDialog" data-vv-scope="whenConsult">
                <table
                  class="form-table"
                  cellspacing="0"
                  cellpadding="0"
                  border="0"
                >
                  <tbody>
                    <tr>
                      <th width="100px">脚本内容:</th>
                      <td>
                        <!-- 常用脚本选择对话框  -->
                        <eip-script-dialog
                          ref="whenConsult"
                          v-model="dataDialog.whenConsult"
                          append-to-body
                        />
                        <el-button @click="showDialog('whenConsult')"
                          >常用脚本</el-button
                        >
                        <!-- 可选变量对话框 -->
                        <flow-var-selector
                          :defId="defId"
                          @node-click="varTreeConfirm($event, 'whenConsult')"
                        />
                        <br />
                        <br />
                        <ht-input
                          type="textarea"
                          :rows="14"
                          class="ht"
                          v-model="dataDialog.whenConsult"
                          placeholder="请输入脚本内容"
                          autocomplete="off"
                        ></ht-input>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </el-form>
            </el-tab-pane>
            <el-tab-pane label="流转时" name="whenRoam">
              <el-form v-model="dataDialog" data-vv-scope="whenRoam">
                <table
                  class="form-table"
                  cellspacing="0"
                  cellpadding="0"
                  border="0"
                >
                  <tbody>
                    <tr>
                      <th width="100px">脚本内容:</th>
                      <td>
                        <!-- 常用脚本选择对话框  -->
                        <eip-script-dialog
                          ref="whenRoam"
                          v-model="dataDialog.whenRoam"
                          append-to-body
                        />
                        <el-button @click="showDialog('whenRoam')"
                          >常用脚本</el-button
                        >
                        <!-- 可选变量对话框 -->
                        <flow-var-selector
                          :defId="defId"
                          @node-click="varTreeConfirm($event, 'whenRoam')"
                        />
                        <br />
                        <br />
                        <ht-input
                          type="textarea"
                          :rows="14"
                          class="ht"
                          v-model="dataDialog.whenRoam"
                          placeholder="请输入脚本内容"
                          autocomplete="off"
                        ></ht-input>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </el-form>
            </el-tab-pane>
            <el-tab-pane label="加签时" name="whenAddSign">
              <el-form v-model="dataDialog" data-vv-scope="whenAddSign">
                <table
                  class="form-table"
                  cellspacing="0"
                  cellpadding="0"
                  border="0"
                >
                  <tbody>
                    <tr>
                      <th width="100px">脚本内容:</th>
                      <td>
                        <!-- 常用脚本选择对话框  -->
                        <eip-script-dialog
                          ref="whenAddSign"
                          v-model="dataDialog.whenAddSign"
                          append-to-body
                        />
                        <el-button @click="showDialog('whenAddSign')"
                          >常用脚本</el-button
                        >
                        <!-- 可选变量对话框 -->
                        <flow-var-selector
                          :defId="defId"
                          @node-click="varTreeConfirm($event, 'whenAddSign')"
                        />
                        <br />
                        <br />
                        <ht-input
                          type="textarea"
                          :rows="14"
                          class="ht"
                          v-model="dataDialog.whenAddSign"
                          placeholder="请输入脚本内容"
                          autocomplete="off"
                        ></ht-input>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </el-form>
            </el-tab-pane>
          </el-tabs>
          <br />
          <br />
        </div>
      </div>
      <div slot="footer" class="dialog-footer" style="float: right;">
        <el-button size="mini" @click="close">取消</el-button>
        <el-button type="primary" size="mini" @click="saveDataDialog"
          >保存</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {Message} from 'element-ui'
import req from '@/request.js'
const eipScriptDialog = () => import('@/components/dialog/EipScriptDialog.vue')
const FlowVarSelector = () => import('@/components/flow/FlowVarSelector.vue')
const FlowConditionBuildDialog = () =>
  import('@/components/flow/FlowConditionBuildDialog.vue')
export default {
  name: 'FlowEditBoSetting',
  components: {FlowVarSelector, FlowConditionBuildDialog, eipScriptDialog},
  props: {
    defId: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      tabType: 'beforeShow',
      treeData: [], //树数据
      defaultProps: {
        children: 'children',
        label: 'desc',
      },
      dialogVisibleSetting: false, //是否显示Bo任务节点设置
      selectedNode: '', //选择的节点
      nodeDefList: [], //可选择的节点
      nodeSetMap: {}, //节点设置的数据
      isClearForm: false, //是否清空已配置的表单
      data: {bodef: {boSaveMode: 'database', boDefs: []}},
      dataDialog: {
        beforeShow: '', //显示前
        whenSave: '', //保存时
        whenAgree: '', //同意时
        whenOppose: '', //反对时
        whenConsult: '', //征询时
        whenRoam: '', //流转时
        whenAddSign: '', //加签时
        whenReject: '', //驳回时
        defKey: '',
        description: '',
      }, //Bo任务节点设置对话框返回的值
      isEdit: false, //是否是点击修改按钮进入的Bo任务节点设置对话框,
      curEditIndex: null,
      curEditNodeId: '',
      typeArray: [
        {
          typeKey: 'beforeShow',
          settingKey: 'showFieldsSetting',
        },
        {
          typeKey: 'whenSave',
          settingKey: 'saveFieldsSetting',
        },
        {
          typeKey: 'whenAgree',
          settingKey: 'agreeFieldsSetting',
        },
        {
          typeKey: 'whenReject',
          settingKey: 'rejectFieldsSetting',
        },
        {
          typeKey: 'whenOppose',
          settingKey: 'opposeFieldsSetting',
        },
        {
          typeKey: 'whenAddSign',
          settingKey: 'addSignFieldsSetting',
        },
        {
          typeKey: 'whenRoam',
          settingKey: 'roamFieldsSetting',
        },
        {
          typeKey: 'whenConsult',
          settingKey: 'consultFieldsSetting',
        },
      ],
    }
  },
  computed: {
    nodeOptions() {
      if (!this.nodeDefList) {
        return []
      }
      return this.nodeDefList.map((node) => {
        node.label = `${node.name}(${node.nodeId})`
        return node
      })
    },
  },
  methods: {
    //Bo任务节点设置对话框确认事件
    saveDataDialog() {
      if (!this.dataDialog.description) {
        this.$message.warning('请输入描述')
        return
      }
      //判断是否是修改
      if (!this.isEdit) {
        //不是修改
        let list = this.nodeSetMap[this.selectedNode]
        if (!list) {
          this.nodeSetMap[this.selectedNode] = []
          list = this.nodeSetMap[this.selectedNode]
        }
        list.push(this.dataDialog)
        this.isEdit = false
      } else {
        this.nodeSetMap[this.curEditNodeId].splice(
          this.curEditIndex,
          1,
          this.dataDialog
        )
      }
      this.dialogVisibleSetting = false
    },
    //监督可选变量的返回值(显示前)
    varTreeBeforeShow(data) {
      this.dataDialog.beforeShow = this.dataDialog.beforeShow + data.pathValue
    },
    //监督可选变量的返回值(保存时)
    varTreeWhenSave(data) {
      this.dataDialog.whenSave = this.dataDialog.whenSave + data.pathValue
    },
    varTreeConfirm(data, field) {
      this.dataDialog[field] += data.pathValue
    },
    //显示常用脚本
    showDialog(action) {
      this.$refs[action].showDialog()
    },
    //树鼠标左击事件(treeNode:当前节点对象,node:可以拿到父节点对象)
    handleNodeClick(treeNode, node, nodeCompent) {
      let def
      let pDef //父定义
      if (!treeNode.nodeType || treeNode.nodeType == 'main') {
        return
      }
      if (treeNode.nodeType == 'field') {
        def = node.parent
      } else {
        def = node
      }
      if (def.data.nodeType == 'sub') {
        pDef = def.parent
      }
      if (!this.dataDialog.description) {
        this.dataDialog.description = treeNode.desc
      }
      let txt = ''
      if (treeNode.nodeType == 'field') {
        //字段
        if (!pDef) {
          //主表字段
          pDef = def
          txt =
            pDef.data.boDefAlias +
            '.get("data").put("' +
            treeNode.name +
            '","");'
        } else {
          //子表字段
          if (this.tabType == 'beforeShow') {
            if (pDef.data.nodeType == 'sub') {
              //孙表
              const rootDef = pDef.parent
              txt += '//设置新增孙表的默认值\n\r'
              txt +=
                rootDef.data.boDefAlias +
                '.get("initDataMap").get("' +
                pDef.data.name +
                '").get("initData").get("' +
                def.data.name +
                '").put("' +
                treeNode.name +
                '","");'
            } else {
              txt += '//设置新增子表的默认值\n\r'
              txt +=
                pDef.data.boDefAlias +
                '.get("initDataMap").get("' +
                def.data.name +
                '").put("' +
                treeNode.name +
                '","");'
            }
          } else {
            if (pDef.data.nodeType == 'sub') {
              //孙表
              const rootDef = pDef.parent
              txt +=
                '//设置已有子表某个字段的值,参数为(子表名,孙表名,孙表字段名,字段值,子表下标,孙表下标)或(子表名,孙表名,孙表字段名,字段值,子表下标)或(子表名,孙表名,孙表字段名,字段值)无下标每条数据都会修改\n\r'
              txt +=
                rootDef.data.boDefAlias +
                '.setSunFiledVal("' +
                pDef.data.name +
                '","' +
                def.data.name +
                '","' +
                treeNode.name +
                '","",0,0);'
            } else {
              txt +=
                '//设置已有子表某个字段的值,参数为(子表名,字段名,字段值,下标)或者(子表名,字段名,字段值),无下标每条数据都会修改\n\r'
              txt +=
                pDef.data.boDefAlias +
                '.setSubFiledVal("' +
                def.data.name +
                '","' +
                treeNode.name +
                '","",0);'
            }
          }
        }
      } else {
        //子表
        txt =
          'ArrayNode list = ' +
          pDef.data.boDefAlias +
          '.getSubTableData("' +
          def.data.name +
          '");'
      }
      // if (this.tabType == 'beforeShow') {
      //   //如果是显示前
      //   this.dataDialog.beforeShow = this.dataDialog.beforeShow + txt
      // } else if (this.tabType == 'whenSave') {
      //   //如果是保存时
      //   this.dataDialog.whenSave = this.dataDialog.whenSave + txt
      // }
      let array = this.typeArray.filter((item) => item.typeKey === this.tabType)
      if (array.length > 0) {
        this.dataDialog[array[0].typeKey] =
          this.dataDialog[array[0].typeKey] + txt
      }
      this.dataDialog.defKey = pDef.data.boDefAlias
    },
    //根据任务节点ID获取任务节点名称
    getDesc(nodeId) {
      for (let i = 0; i < this.nodeDefList.length; i++) {
        let tmp = this.nodeDefList[i]
        if (tmp.nodeId == nodeId) {
          return tmp.name + '(' + nodeId + ')'
        }
      }
      return nodeId
    },
    //添加
    editNodeSet(editNodeId, index, nodeSet) {
      let passConf = {}
      passConf.node = this.selectedNode
      passConf.ids = ''
      this.data.bodef.boDefs.forEach((item) => {
        if (passConf.ids != '') {
          passConf.ids += ','
        }
        passConf.ids += item.id
      })
      //判断是否从编辑进来的
      if (nodeSet) {
        passConf.data = nodeSet
        for (let i = 0; i < this.nodeDefList.length; i++) {
          let tmp = this.nodeDefList[i]
          if (tmp.nodeId == nodeId) {
            passConf.node = tmp
            break
          }
        }
        this.dataDialog = JSON.parse(JSON.stringify(nodeSet)) //给显示前和保存时的脚本内容赋值
        this.curEditIndex = index
        this.curEditNodeId = editNodeId
        this.isEdit = true
      } else if (!nodeSet) {
        this.isEdit = false
        this.dataDialog = {
          beforeShow: '',
          whenSave: '',
          whenAgree: '',
          whenConsult: '',
          whenOppose: '',
          whenRoam: '',
          whenAddSign: '',
          whenReject: '',
          defKey: '',
          description: '',
        } //初始化显示前和保存时的脚本内容
      }
      if (!passConf.ids) {
        Message.warning('请在流程配置中先绑定表单')
        return
      }
      let nodeId = passConf.node.nodeId
      const this_ = this
      //显示BO数据树
      req
        .post('${form}/bo/def/v1/getBOTree', passConf.ids)
        .then(function (res) {
          this_.treeData = []
          this_.treeData.push(res.data)
          this_.tabType = 'beforeShow'
          this_.dialogVisibleSetting = true
        })
    },
    //保存
    save(isRest) {
      let data = this.data
      //判断是否绑定表单
      if (data.bodef.boDefs.length == 0) {
        Message.warning('请在流程配置中先绑定表单')
        return
      }
      // 拼装提交的数据
      data.bodef.boDefs.forEach((item) => {
        item.key = item.alias
      })
      data.formInitItems = []
      if (this.nodeSetMap.length != 0) {
        for (let key in this.nodeSetMap) {
          let temp = {}
          temp.nodeId = key
          temp.parentDefKey = ''
          this.typeArray.forEach((item) => {
            temp[item.settingKey] = []
          })
          this.nodeSetMap[key].forEach((item) => {
            // 都为空就不保存
            if (
              !item.beforeShow &&
              !item.whenSave &&
              !item.whenAgree &&
              !item.whenOppose &&
              !item.whenAddSign &&
              !item.whenRoam &&
              !item.whenConsult &&
              !item.whenReject
            ) {
              return
            }

            this.typeArray.forEach((data) => {
              let tmp = {}
              tmp.boDefCode = item.defKey
              tmp.description = item.description
              tmp.setting = item[data.typeKey] || ''
              temp[data.settingKey].push(tmp)
            })
          })
          data.formInitItems.push(temp)
        }
      }
      let param = {}
      param.json = JSON.stringify(data)
      param.topDefKey = ''
      param.flowId = this.defId
      param.isClearForm = this.isClearForm

      req.post('${bpmModel}/flow/def/v1/saveSetBos', param).then(function (r) {
        r = r.data
        let opName = '保存'
        if (isRest) {
          opName = '重置'
        }
        if (r.state) {
          Message.success(opName + '成功')
        } else {
          Message.error(opName + '失败')
        }
      })
    },
    //重置
    reset() {
      this.$confirm('此操作将清除所有数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          this.nodeSetMap = {}
          this.save(true)
        })
        .catch(() => {})
    },
    //关闭侧边栏
    close() {
      this.dialogVisibleSetting = false
      this.isEdit = false
    },
    //删除
    deleteSetting(list, index) {
      list.splice(index, 1)
    },
  },
  mounted() {
    this.$loading()
    this.$validator = this.$root.$validator
    const this_ = this
    let url =
      '${bpmModel}/flow/def/v1/nodeBos?defId=' + this.defId + '&topDefKey='
    req.get(url).then(function (data) {
      data = data.data
      this_.nodeDefList = data.nodeDefList
      this_.selectedNode = data.nodeDefList[0].nodeId // 默认选一个
      // 初始化json的数据
      if (data.json.bodef.boSaveMode) {
        this_.data.bodef.boSaveMode = data.json.bodef.boSaveMode
      }
      if (data.json.bodef) {
        for (let x = 0; x < data.json.bodef.boDefs.length; x++) {
          let item = data.json.bodef.boDefs[x]
          let temp = {}
          temp.alias = item.key
          temp.name = item.name
          temp.scope = item.scope
          req
            .get('${form}/bo/def/v1/getObject?key=' + item.key)
            .then(function (req) {
              req = req.data
              temp.id = req.id
              this_.data.bodef.boDefs.push(temp)
              //最后一个索引的元素时关系加载框
              if (x == data.json.bodef.boDefs.length - 1) {
                this_.$loading().close()
              }
            })
        }
      }
      if (data.json.formInitItems) {
        data.json.formInitItems.forEach((item) => {
          for (let i = 0; i < item.saveFieldsSetting.length; i++) {
            let temp = {}
            temp.description = item.saveFieldsSetting[i].description
            temp.defKey = item.saveFieldsSetting[i].boDefCode
            this_.typeArray.forEach((typeObj) => {
              if (
                item &&
                item[typeObj.settingKey] &&
                item[typeObj.settingKey].length > 0
              ) {
                temp[typeObj.typeKey] = item[typeObj.settingKey][i].setting
              }
            })
            let list = this_.nodeSetMap[item.nodeId]
            if (!list) {
              this_.nodeSetMap[item.nodeId] = []
              list = this_.nodeSetMap[item.nodeId]
            }
            list.push(temp)
          }
        })
      }
      this_.$loading().close()
    })
  },
}
</script>
<style lang="scss" scoped>
.htTypeTree {
  ::v-deep .el-tree-node__expand-icon {
    color: #333333;
  }
  ::v-deep .el-tree-node__expand-icon.is-leaf {
    color: transparent !important;
  }
}
div >>> .el-dialog__body {
  padding: 10px 20px;
  color: #606266;
  font-size: 14px;
  word-break: break-all;
}
.el-main {
  padding-top: 0px;
}
.urgent-text {
  width: 100%;
}
.ht {
  width: 100%;
  ::v-deep {
    .el-textarea__inner {
      resize: both;
      width: 650px;
      max-width: 760px;
    }
  }
}
::v-deep .el-tabs__content {
  overflow: auto;
  position: relative;
  max-height: 370px;
}

.bo-set__card {
  height: calc(100% - 5px);
  border: none;
}

.bo-set__card /deep/ > div.el-card__header {
  padding: 16px;
  border: none;
}

.bo-set__card /deep/ > div.el-card__body {
  height: calc(100% - 65px);
  padding: 0;
}
.scrollbar-title {
  margin-top: 24px;
  color: #333333;
  font-weight: bold;
}
.bo-set__table th,
.bo-set__card /deep/ > div.el-card__header,
.bo-set__detail /deep/ > .el-table__header-wrapper > table > thead th {
  background: #f9f9f9;
}
.bo-set__table th,
.bo-set__table td {
  padding: 16px 0px !important;

  border: none;
  &:last-child {
    padding-bottom: 0;
  }
}
td {
  border: none !important;
}
.dialog-footer {
  margin-top: -25px;
}
.wrap {
  display: flex;
}
.is-plain {
  background: #fff;
  color: #409eff;
}
.top-button {
  right: 24px;
  top: 9px;
  z-index: 10000000;
  position: fixed;
}
.form-table {
  .table_lable {
    padding: 24px;
    text-align: left;
    border: none;
    color: #888888;
  }
  .ht-form-inputs__inline {
    width: 100%;
  }
  th {
    border: none;
  }
  ::v-deep .ht-textarea {
    border: none;
    .el-textarea__inner {
      background: #f3f3f3;
    }
  }
  .el-tabs__nav {
    .is-active {
      font-weight: bold;
    }
  }
  .often-button {
    margin-right: 16px;
  }
}
</style>