CommonProperty.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <div>
  3. <el-form label-width="130px" :model="formData">
  4. <el-form-item label="节点名称">
  5. <el-input v-model="formData.text" :disabled="readonly"></el-input>
  6. </el-form-item>
  7. <el-form-item label="审核方式" v-if="nodeType===NodeTypeStart">
  8. <el-select v-model="formData.actionRule" placeholder="请选择审核方式" clearable :disabled="readonly">
  9. <el-option v-for="item in actionRuleOption"
  10. :key="item.value"
  11. :label="item.label"
  12. :value="item.value"
  13. />
  14. </el-select>
  15. </el-form-item>
  16. <el-form-item label="接收方式" v-else>
  17. <el-select v-model="formData.actionRule" placeholder="请选择接收方式" clearable :disabled="readonly">
  18. <el-option v-for="item in actionRuleOption"
  19. :key="item.value"
  20. :label="item.label"
  21. :value="item.value"
  22. />
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="指定上级部门" v-show="formData.actionRule===FlowCheckRuleFormCreatorDeptPrev || formData.actionRule===FlowCheckRuleFormCreatorDeptLeaderPrev">
  26. <el-input-number
  27. v-model="formData.deptProv"
  28. style="width: 200px"
  29. placeholder="Please input"
  30. >
  31. <template #prefix><span>上</span></template>
  32. <template #suffix><span>级部门</span></template>
  33. </el-input-number>
  34. </el-form-item>
  35. <el-form-item label="指定角色" v-show="formData.actionRule===FlowCheckRuleRole">
  36. <el-cascader
  37. :options="roleList"
  38. :props="{ checkStrictly: true,emitPath: false, value: 'id', label: 'name',multiple: true }"
  39. placeholder="请选择角色"
  40. clearable
  41. class="w100"
  42. v-model="formData.roleIds"
  43. :disabled="readonly"
  44. >
  45. <template #default="{ node, data }">
  46. <span>{{ data.name }}</span>
  47. <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
  48. </template>
  49. </el-cascader>
  50. </el-form-item>
  51. <el-form-item label="指定部门" prop="deptId" v-show="formData.actionRule===FlowCheckRuleDept ||formData.actionRule===FlowCheckRuleDeptLeader">
  52. <el-cascader
  53. :options="deptData"
  54. :props="{ checkStrictly: true,emitPath: false, value: 'deptId', label: 'deptName',multiple: true }"
  55. placeholder="请选择部门"
  56. clearable
  57. class="w100"
  58. v-model="formData.deptIds"
  59. :disabled="readonly"
  60. >
  61. <template #default="{ node, data }">
  62. <span>{{ data.deptName }}</span>
  63. <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
  64. </template>
  65. </el-cascader>
  66. </el-form-item>
  67. <el-form-item label="指定岗位" prop="postIds" v-show="formData.actionRule===FlowCheckRulePost">
  68. <el-select v-model="formData.postIds" placeholder="请选择" clearable class="w100" multiple :disabled="readonly">
  69. <el-option
  70. v-for="post in postList"
  71. :key="'post-'+post.postId"
  72. :label="post.postName"
  73. :value="post.postId">
  74. </el-option>
  75. </el-select>
  76. </el-form-item>
  77. <el-form-item label="指定人员" v-show="formData.actionRule===FlowCheckRuleUser">
  78. <select-user v-model="formData.userIds"></select-user>
  79. </el-form-item>
  80. <el-form-item label="多人审批处理规则" >
  81. <el-select v-model="formData.approveRule" placeholder="请选择多人审批处理规则" style="width: 100%" :disabled="readonly">
  82. <el-option v-for="item in approveRuleOption"
  83. :key="item.value"
  84. :label="item.label"
  85. :value="item.value"
  86. />
  87. </el-select>
  88. </el-form-item>
  89. <el-form-item label="网关审批处理规则" v-show="nodeType===NodeTypeConcurrent||nodeType===NodeTypePush||nodeType===NodeTypeCondition">
  90. <el-select v-model="nodeType" placeholder="请选择多人审批处理规则" :disabled="true" style="width: 100%">
  91. <el-option v-for="item in conditionRuleOption"
  92. :key="item.value"
  93. :label="item.label"
  94. :value="item.value"
  95. />
  96. </el-select>
  97. </el-form-item>
  98. <el-form-item label="发送通知" >
  99. <el-checkbox-group v-model="formData.notice" :disabled="readonly">
  100. <el-checkbox value="sms" >短信</el-checkbox>
  101. <el-checkbox value="email" >邮件</el-checkbox>
  102. <el-checkbox value="innerNotice" >站内通知</el-checkbox>
  103. </el-checkbox-group>
  104. </el-form-item>
  105. <el-form-item label="允许退回" v-show="nodeType!==NodeTypeStart">
  106. <el-radio-group v-model="formData.rollback" :disabled="readonly">
  107. <el-radio :value="1">是</el-radio>
  108. <el-radio :value="0">否</el-radio>
  109. </el-radio-group>
  110. </el-form-item>
  111. <el-form-item label="分支条件" v-show="nodeType===NodeTypeCondition">
  112. <Branch ref="branchRef" :modelValue="formData.nodeExt" @setNodeExt="setNodeExt"></Branch>
  113. </el-form-item>
  114. <el-form-item>
  115. <el-button type="primary" @click="onSubmit" v-if="!readonly">保存</el-button>
  116. </el-form-item>
  117. </el-form>
  118. </div>
  119. </template>
  120. <script setup lang="ts">
  121. import {NodeConditionData} from "/@/components/gFlow/propertySetting/model";
  122. interface UserInfo {
  123. userNickname:string;
  124. userId:number;
  125. }
  126. interface PostInfo{
  127. postId:number;
  128. postName:string;
  129. }
  130. import {getDeptTree, getParams, getUserByIds} from "/@/api/system/user";
  131. import selectUser from "/@/components/selectUser/index.vue";
  132. import LogicFlow from "@logicflow/core";
  133. import {computed, getCurrentInstance, onMounted, reactive, ref, toRefs} from "vue";
  134. import Branch from "/@/components/gFlow/propertySetting/branch.vue"
  135. import {
  136. FlowCheckRuleAll,
  137. FlowCheckRuleDept,
  138. FlowCheckRuleDeptLeader,
  139. FlowCheckRuleFormCreator,
  140. FlowCheckRuleFormCreatorDept,
  141. FlowCheckRuleFormCreatorDeptLeader,
  142. FlowCheckRuleFormCreatorDeptPrev,
  143. FlowCheckRuleFormCreatorDeptLeaderPrev,
  144. FlowCheckRulePost,
  145. FlowCheckRuleRole,
  146. FlowCheckRuleUser, NodeTypeConcurrent, NodeTypeCondition, NodeTypePush, NodeTypeStart
  147. } from "/@/components/gFlow/consts";
  148. defineOptions({ name: "CommonProperty"})
  149. const branchRef = ref()
  150. const { proxy } = <any>getCurrentInstance();
  151. const props = defineProps({
  152. nodeData: {
  153. type: Object,
  154. default: () => {
  155. return null
  156. }
  157. },
  158. lf:{
  159. type:LogicFlow,
  160. default: () => {
  161. return {} as LogicFlow
  162. }
  163. },
  164. readonly:{
  165. type:Boolean,
  166. default:false
  167. }
  168. })
  169. const nodeType = computed(()=>{
  170. return props.nodeData.type.replace('Done','')
  171. })
  172. const emit = defineEmits(['onClose'])
  173. const selectUserRef =ref()
  174. const state = reactive({
  175. text: '',
  176. roleList:[],//角色选项列表
  177. postList:[] as PostInfo[],//岗位选项列表
  178. deptData:[],//部门选项列表
  179. actionRuleOption:[
  180. {
  181. label:'任何人',
  182. value:FlowCheckRuleAll
  183. },
  184. {
  185. label:'指定角色',
  186. value:FlowCheckRuleRole
  187. },
  188. {
  189. label:'指定部门',
  190. value:FlowCheckRuleDept
  191. },
  192. {
  193. label:'指定部门负责人',
  194. value:FlowCheckRuleDeptLeader
  195. },
  196. {
  197. label:'指定人员',
  198. value:FlowCheckRuleUser
  199. },
  200. {
  201. label:'指定岗位',
  202. value:FlowCheckRulePost
  203. },
  204. {
  205. label:'表单业务创建人',
  206. value:FlowCheckRuleFormCreator
  207. },
  208. {
  209. label:'表单业务创建人所属部门',
  210. value:FlowCheckRuleFormCreatorDept
  211. },
  212. {
  213. label:'表单业务创建人所属部门负责人',
  214. value:FlowCheckRuleFormCreatorDeptLeader
  215. },
  216. {
  217. label:'表单业务创建人所属上级部门',
  218. value:FlowCheckRuleFormCreatorDeptPrev
  219. },
  220. {
  221. label:'表单业务创建人所属上级部门负责人',
  222. value:FlowCheckRuleFormCreatorDeptLeaderPrev
  223. }
  224. ],
  225. approveRuleOption:[
  226. {
  227. label:'抢办模式(任何人第一个处理则通过)',
  228. value:1
  229. },
  230. {
  231. label:'顺序执行(所有人按顺序执行完才通过)',
  232. value:2
  233. },
  234. {
  235. label:'并行执行(所有人执行完才通过)',
  236. value:3
  237. },
  238. ],
  239. //分支条件审核规则
  240. conditionRuleOption:[
  241. {label:"并行网关-所有分支都必须完成审核",value:NodeTypeConcurrent},
  242. {label:"互斥网关-所有分支中只能有其中一条审核",value:NodeTypePush},
  243. {label:"条件网关-符合条件的某条分或多条支进行审核",value:NodeTypeCondition},
  244. ],
  245. formData: {
  246. text: '',
  247. actionRule: undefined,
  248. roleIds:[],
  249. deptIds:[],
  250. userIds:[],
  251. postIds:[],
  252. approveRule:'',
  253. notice:[],
  254. rollback:undefined,
  255. nodeExt:[] as Array<NodeConditionData[]>,
  256. deptProv:1
  257. }
  258. })
  259. const { formData, deptData, roleList, postList, actionRuleOption, approveRuleOption, conditionRuleOption} = toRefs(state)
  260. onMounted(()=>{
  261. const { properties, text } = props.nodeData
  262. if (properties) {
  263. state.formData = Object.assign({}, state.formData, properties)
  264. //设置条件
  265. branchRef.value.initNodeData(state.formData.nodeExt)
  266. }
  267. if (text && text.value) {
  268. state.formData.text = text.value
  269. }
  270. if (text && text.value) {
  271. state.text = text.value
  272. }
  273. getSelector()
  274. })
  275. const getSelector = () =>{
  276. //获取角色岗位选项
  277. getParams().then((res)=>{
  278. const roles = res.data.roleList??[];
  279. const roleAccess = res.data.roleAccess??[];
  280. roles.map((item:any)=>{
  281. if(!roleAccess.includes(item.id)){
  282. item.disabled = true
  283. }
  284. })
  285. state.roleList = proxy.handleTree(roles??[], "id","pid","children",true);
  286. state.postList = res.data.posts??[];
  287. });
  288. getDeptTree().then((res)=>{
  289. state.deptData = res.data.deps
  290. })
  291. }
  292. const onSubmit = () =>{
  293. branchRef.value.setNodeExt()
  294. const { id } = props.nodeData
  295. props.lf.setProperties(id, {
  296. ...state.formData
  297. });
  298. props.lf.updateText(id, state.formData.text);
  299. emit('onClose')
  300. }
  301. const setNodeExt = (data:Array<NodeConditionData[]>) =>{
  302. state.formData.nodeExt = data
  303. }
  304. </script>
  305. <style scoped>
  306. </style>