index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. // 开始节点配置界面
  2. /* eslint-disable vue/no-side-effects-in-computed-properties */
  3. <template>
  4. <div class="InformationBlock">
  5. <div class="content">
  6. <div :class="`form_content rule_content`">
  7. <div class="form">
  8. <p >
  9. <span class="label">优先级:</span>
  10. <Input type="text" :disabled="readOnly" v-model="configData.priority" :regx="/^[0-9]*$/" />
  11. </p>
  12. <p v-if="moduleType === 1">
  13. <span class="label"><i class="requireStyle">*</i>单据类型:</span>
  14. <DropDownSelectFilter
  15. :disabled="readOnly"
  16. v-bind="tableConfig.props"
  17. v-on="tableConfig.event"
  18. >
  19. </DropDownSelectFilter>
  20. </p>
  21. <p v-if="moduleType === 1">
  22. <span class="label">查询索引:</span>
  23. <DropDownSelectFilter
  24. :disabled="readOnly"
  25. v-bind="indexQuery.props"
  26. v-on="indexQuery.event"
  27. >
  28. </DropDownSelectFilter>
  29. </p>
  30. <p v-if="moduleType === 1">
  31. <span class="label">触发按钮:</span>
  32. <Select v-model="configData.triggerBt" :disabled="readOnly" multiple @on-change="triggerBtChange">
  33. <Option v-for="(item,index) in triggerButtons" :key="index" :value="item.ID">{{item.Label}}</Option>
  34. </Select>
  35. </p>
  36. <p v-if="moduleType === 1">
  37. <span class="label">可见按钮:</span>
  38. <Select v-model="configData.visibleBt" :disabled="readOnly" multiple @on-change="visibleBtChange">
  39. <Option v-for="(item,index) in visibleButtons" :key="index" :value="item.ID">{{item.Label}}</Option>
  40. </Select>
  41. </p>
  42. </div>
  43. <div class="rule">
  44. <p class="title">
  45. <span>配置规则</span>
  46. <span @click="addRule" v-if="!readOnly">添加规则</span>
  47. </p>
  48. <div class="form" v-if="configData.ruleList.length >= 2">
  49. <p >
  50. <span class="label">规则并行条件:</span>
  51. <Select v-model="configData.conditionType" >
  52. <Option :value="0" :key="0">且</Option>
  53. <Option :value="1" :key="1">或</Option>
  54. </Select>
  55. </p>
  56. </div>
  57. <div class="ruleContent" v-if="configData.ruleList.length > 0">
  58. <RuleConfigurationComponent
  59. v-for="(rule,index) in configData.ruleList"
  60. v-bind:key="Math.random()"
  61. :data="rule"
  62. :index="index"
  63. :TABLE_ID="[{ID:configData.businessType,Label:configData.businessTypeName}]"
  64. :readOnly="readOnly"
  65. >
  66. <span slot="delete" class="deleteIcon" @click.stop="delectRule(index)" v-if="!readOnly">
  67. <i class="iconfont iconbj_delete"></i>
  68. </span>
  69. </RuleConfigurationComponent>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. <p>
  75. <Button type="fcdefault" @click="closeDrawer">取消</Button>
  76. <Button type="primary" @click="saveConfig" v-if="!readOnly">确定</Button>
  77. </p>
  78. </div>
  79. </template>
  80. <script>
  81. import ProcessNodeConfig from '@/components/ProcessNodeConfig'
  82. import RuleConfigurationComponent from '@/components/RuleConfigurationComponent'
  83. export default {
  84. name:'startNodeInfo',
  85. components:{RuleConfigurationComponent},
  86. props:{
  87. configData:{
  88. },
  89. TABLE_ID:{}, //主表数据
  90. status:null,
  91. readOnly:{
  92. type:Boolean,
  93. default:false
  94. },
  95. moduleType:{
  96. type: Number,
  97. default: 0
  98. }
  99. },
  100. computed: {
  101. defaultData () {
  102. // eslint-disable-next-line vue/no-side-effects-in-computed-properties
  103. this.infoData = this.configData
  104. return this.configData
  105. },
  106. currentComponent () {
  107. return ProcessNodeConfig
  108. }
  109. },
  110. watch:{
  111. defaultData:{
  112. handler () {
  113. this.infoData = this.defaultData
  114. },
  115. deep:true
  116. }
  117. },
  118. data () {
  119. return {
  120. infoData:[],
  121. defaultObj:{},
  122. triggerButtons:[],// 触发按钮
  123. visibleButtons:[], // 可见按钮
  124. //节点表的配置
  125. tableConfig:{
  126. props:{
  127. columnsKey: ['NAME'],
  128. AutoData: [],
  129. hidecolumns: ['id'],
  130. data: {},
  131. totalRowCount: 0,
  132. defaultSelected: [],
  133. isBackRowItem: true
  134. },
  135. event:{
  136. 'on-input-value-change': (value) => {
  137. // 外键的模糊搜索
  138. this.tableConfig.props.AutoData = []
  139. this.$network.post('/p/c/meta/table/list',{DESCRIPTION:value}).then(res => {
  140. if(res.data.code === 0){
  141. // this.row = res.data.data.row.concat([])
  142. this.tableConfig.props.AutoData = res.data.data.row.reduce((arr,item) => {
  143. arr.push({
  144. value:item.NAME.val,
  145. id:item.ID.val,
  146. NAME:item.DESCRIPTION.val
  147. })
  148. return arr
  149. },[]);
  150. }
  151. })
  152. },
  153. 'on-popper-show': ($this) => {
  154. // 当外键下拉站开始去请求数据
  155. // this.freshDropDownSelectFilterData($this)
  156. this.$network.post('/p/c/meta/table/list',{
  157. pageSize:$this.pageSize,
  158. page:1
  159. }).then(res => {
  160. if(res.data.code === 0){
  161. res.data.data.tabth.forEach(item => {
  162. if(item.colname === 'DESCRIPTION'){
  163. item.isak = true
  164. }
  165. return item
  166. })
  167. this.tableConfig.props.data = res.data.data;
  168. this.tableConfig.props.totalRowCount = res.data.data.totalRowCount;
  169. }
  170. })
  171. },
  172. 'on-page-change': (currentPage, $this) => {
  173. // 外键的分页查询
  174. // this.freshDropDownSelectFilterData($this,currentPage)
  175. this.$network.post('/p/c/meta/table/list',{
  176. pageSize:$this.pageSize,
  177. page:currentPage
  178. }).then(res => {
  179. if(res.data.code === 0){
  180. res.data.data.tabth.forEach(item => {
  181. if(item.colname === 'DESCRIPTION'){
  182. item.isak = true
  183. }
  184. return item
  185. })
  186. this.tableConfig.props.data = res.data.data;
  187. this.tableConfig.props.totalRowCount = res.data.data.totalRowCount;
  188. }
  189. })
  190. },
  191. 'on-blur':(event,instance) => {
  192. // if(Object.prototype.toString.call(this.data.businessType) !== '[object Array]' || this.data.businessType.length === 0){
  193. // instance.inputValue = ''
  194. // /*
  195. // todo
  196. // 清空所有和主表有关的数据
  197. // */
  198. // }
  199. },
  200. 'on-fkrp-selected': (value) => {
  201. if(value.length > 0){
  202. this.configData.businessTypeName = value[0].rowItem.NAME.val?value[0].rowItem.NAME.val:value[0].rowItem.NAME
  203. this.configData.businessType= value[0].ID
  204. this.configData.businessTypeText = value[0].Label
  205. this.getTriggerButtons()
  206. this.getVisibleButtons()
  207. }else{
  208. this.configData.businessTypeName = null
  209. this.configData.businessType = null
  210. this.configData.businessTypeText = null
  211. }
  212. // 清除可显示字段数据
  213. // this.onClear()
  214. this.configData.visibleBt = []
  215. this.configData.triggerBt = []
  216. this.configData.businessKeyId = null
  217. this.configData.businessKey = null
  218. this.configData.businessKeyName = null
  219. this.indexQuery.defaultSelected = []
  220. },
  221. 'on-clear': () => {
  222. // 清除可显示字段数据
  223. // this.onClear()
  224. this.configData.visibleBt = []
  225. this.configData.triggerBt = []
  226. this.configData.businessKeyId = null
  227. this.configData.businessKey = null
  228. this.configData.businessKeyName = null
  229. this.indexQuery.defaultSelected = []
  230. this.configData.businessTypeName = null
  231. this.configData.businessType = null
  232. this.configData.businessTypeText = null
  233. this.tableConfig.props.AutoData = []
  234. this.$network.post('/p/c/meta/table/list',{DESCRIPTION:''}).then(res => {
  235. if(res.data.code === 0){
  236. this.tableConfig.props.AutoData = res.data.data.row.reduce((arr,item) => {
  237. arr.push({
  238. value:item.NAME.val,
  239. id:item.ID.val,
  240. NAME:item.DESCRIPTION.val
  241. })
  242. return arr
  243. },[]);
  244. }
  245. })
  246. }
  247. }
  248. },
  249. // 查询索引
  250. indexQuery:{
  251. props:{
  252. columnsKey: ['NAME'],
  253. AutoData: [],
  254. hidecolumns: ['id'],
  255. data: {},
  256. totalRowCount: 0,
  257. defaultSelected: [],
  258. isBackRowItem: true
  259. },
  260. event:{
  261. 'on-input-value-change': (value,instance) => {
  262. if(!this.configData.businessType){
  263. this.$Modal.fcWarning({
  264. title:'警告',
  265. content:'请先选择节点表!'
  266. })
  267. this.configData.businessKeyId = null
  268. this.configData.businessKey = null
  269. this.configData.businessKeyName = null
  270. instance.inputValue = ''
  271. return
  272. }
  273. // 外键的模糊搜索
  274. this.indexQuery.props.AutoData = []
  275. this.$network.post('/p/c/meta/column/list',{DESCRIPTION:value,AD_TABLE_ID:this.configData.businessType}).then(res => {
  276. if(res.data.code === 0){
  277. // this.row = res.data.data.row.concat([])
  278. this.indexQuery.props.AutoData = res.data.data.row.reduce((arr,item) => {
  279. arr.push({
  280. value:item.NAME.val,
  281. id:item.ID.val,
  282. NAME:item.DESCRIPTION.val
  283. })
  284. return arr
  285. },[]);
  286. }
  287. })
  288. },
  289. 'on-popper-show': ($this) => {
  290. if(!this.configData.businessType){
  291. this.$Modal.fcWarning({
  292. title:'警告',
  293. content:'请先选择节点表!'
  294. })
  295. this.configData.businessKeyId = null
  296. this.configData.businessKey = null
  297. this.configData.businessKeyName = null
  298. $this.inputValue = ''
  299. return
  300. }
  301. // 当外键下拉站开始去请求数据
  302. // this.freshDropDownSelectFilterData($this)
  303. this.$network.post('/p/c/meta/column/list',{
  304. pageSize:$this.pageSize,
  305. page:1,
  306. AD_TABLE_ID:this.configData.businessType
  307. }).then(res => {
  308. if(res.data.code === 0){
  309. res.data.data.tabth.forEach(item => {
  310. if(item.colname === 'DESCRIPTION'){
  311. item.isak = true
  312. }
  313. return item
  314. })
  315. this.indexQuery.props.data = res.data.data;
  316. this.indexQuery.props.totalRowCount = res.data.data.totalRowCount;
  317. }
  318. })
  319. },
  320. 'on-page-change': (currentPage, $this) => {
  321. // 外键的分页查询
  322. // this.freshDropDownSelectFilterData($this,currentPage)
  323. this.$network.post('/p/c/meta/column/list',{
  324. pageSize:$this.pageSize,
  325. page:1,
  326. AD_TABLE_ID:this.configData.businessType
  327. }).then(res => {
  328. if(res.data.code === 0){
  329. res.data.data.tabth.forEach(item => {
  330. if(item.colname === 'DESCRIPTION'){
  331. item.isak = true
  332. }
  333. return item
  334. })
  335. this.indexQuery.props.data = res.data.data;
  336. this.indexQuery.props.totalRowCount = res.data.data.totalRowCount;
  337. }
  338. })
  339. },
  340. 'on-blur':(event,instance) => {
  341. // if(Object.prototype.toString.call(this.data.businessType) !== '[object Array]' || this.data.businessType.length === 0){
  342. // instance.inputValue = ''
  343. // /*
  344. // todo
  345. // 清空所有和主表有关的数据
  346. // */
  347. // }
  348. },
  349. 'on-fkrp-selected': (value) => {
  350. this.configData.businessKey = value[0].rowItem.NAME.val?value[0].rowItem.NAME.val:value[0].rowItem.NAME
  351. this.configData.businessKeyId= value[0].ID
  352. this.configData.businessKeyName = value[0].Label
  353. },
  354. 'on-clear': () => {
  355. // 清除可显示字段数据
  356. // this.onClear()
  357. this.configData.businessKey = null
  358. this.configData.businessKeyId= null
  359. this.configData.businessKeyName = null
  360. this.indexQuery.props.AutoData = []
  361. this.$network.post('/p/c/meta/column/list',{DESCRIPTION:''}).then(res => {
  362. if(res.data.code === 0){
  363. this.indexQuery.props.AutoData = res.data.data.row.reduce((arr,item) => {
  364. arr.push({
  365. value:item.NAME.val,
  366. id:item.ID.val,
  367. NAME:item.DESCRIPTION.val
  368. })
  369. return arr
  370. },[]);
  371. }
  372. })
  373. }
  374. }
  375. },
  376. }
  377. },
  378. created () {
  379. this.defaultObj = JSON.parse(JSON.stringify(this.configData))
  380. if(this.TABLE_ID){ //如果为固定模版
  381. this.configData.businessType = this.TABLE_ID[0].ID
  382. this.configData.businessTypeName = this.TABLE_ID[0].Label
  383. }
  384. if(this.configData.businessType){
  385. this.tableConfig.props.defaultSelected= [
  386. {
  387. ID: this.configData.businessType,
  388. Label: this.configData.businessTypeName
  389. }
  390. ]
  391. this.getTriggerButtons()
  392. this.getVisibleButtons()
  393. }
  394. if(this.configData.businessKeyId){
  395. this.indexQuery.props.defaultSelected= [
  396. {
  397. ID: this.configData.businessKeyId,
  398. Label: this.configData.businessKey
  399. }
  400. ]
  401. }
  402. },
  403. methods:{
  404. addRule () { //添加规则
  405. this.configData.ruleList.push({
  406. name: null,
  407. rule: null,
  408. ruleType: 0,
  409. threshold: {
  410. id:'',
  411. label:''
  412. }
  413. })
  414. },
  415. delectRule (itemIndex) { //删除规则
  416. console.log(itemIndex)
  417. this.configData.ruleList.splice(itemIndex, 1)
  418. this.configData.ruleList.concat([])
  419. this.$set(this.configData.ruleList,this.configData.ruleList)
  420. },
  421. async saveConfig () { //确定按钮点击
  422. await this.inputChange().then(() => { //判断完优先级
  423. // 存在配置规则,校验各项是否必填
  424. let errorFlag = false //判断标志
  425. // 判断单据类型是否必填
  426. if(!this.configData.businessType){
  427. this.$Modal.fcError({
  428. title:'错误',
  429. content:'单据类型不能为空!',
  430. mask: true
  431. })
  432. errorFlag = true
  433. return
  434. }
  435. if(this.configData.ruleList && this.configData.ruleList.length > 0){
  436. this.configData.ruleList.map(item => {
  437. if(item.ruleType === 0 && (!item.fTableInfo || !item.rule || !item.threshold.id)){ //直接选择
  438. this.$Modal.fcError({
  439. title:'错误',
  440. content:'请完善规则配置',
  441. mask: true
  442. })
  443. errorFlag = true
  444. return
  445. }
  446. if(item.ruleType === 1 && !item.businessExpansion){
  447. this.$Modal.fcError({
  448. title:'错误',
  449. content:'请完善规则配置',
  450. mask: true
  451. })
  452. errorFlag = true
  453. return
  454. }
  455. })
  456. }
  457. if(!errorFlag){
  458. this.$emit('closeDrawer')
  459. }
  460. })
  461. },
  462. closeDrawer () { //取消按钮点击
  463. this.$parent.$parent.nodeMsg[Number(this.configData.key)] = this.defaultObj
  464. this.$emit('closeDrawer')
  465. },
  466. async inputChange () { //优先级失去焦点判断
  467. return new Promise((resolve) => {
  468. this.$network.post('/p/cs/node/priority',{
  469. defaultPriority:this.configData.priority,
  470. BUSINESS_TYPE:this.configData.businessType,
  471. id:this.configData.id
  472. }).then(res => {
  473. if(res.data.resultCode === -1){
  474. this.$Modal.fcError({
  475. title:'错误',
  476. content:res.data.resultMsg,
  477. mask:true
  478. })
  479. }
  480. if(res.data.resultCode === 0){
  481. resolve(res)
  482. }
  483. })
  484. })
  485. },
  486. getTriggerButtons () { //获取触发按钮
  487. this.$network.post('/p/cs/node/define/bt',{
  488. id: this.configData.businessType,
  489. vueDispaly: 1
  490. })
  491. .then(res => {
  492. if(res.data.resultCode === 0){
  493. this.triggerButtons = res.data.data.difineData
  494. }else{
  495. this.triggerButtons = []
  496. }
  497. })
  498. },
  499. triggerBtChange (value) { //触发按钮选择
  500. if(value[0] === 'bSelect-all'){
  501. this.configData.triggerBt = this.triggerButtons.reduce((arr,current) => {
  502. arr.push(current.ID)
  503. return arr
  504. },[])
  505. }
  506. },
  507. getVisibleButtons () { //获取可见按钮
  508. this.$network.post('/p/cs/node/define/bt',{
  509. id: this.configData.businessType,
  510. vueDispaly: 0
  511. })
  512. .then(res => {
  513. if(res.data.resultCode === 0){
  514. this.visibleButtons = res.data.data.difineData
  515. }else{
  516. this.visibleButtons = []
  517. }
  518. })
  519. },
  520. visibleBtChange (value) { //可见按钮选择
  521. if(value[0] === 'bSelect-all'){
  522. this.configData.visibleBt = this.visibleButtons.reduce((arr,current) => {
  523. arr.push(current.ID)
  524. return arr
  525. },[])
  526. }
  527. }
  528. }
  529. }
  530. </script>
  531. <style lang="scss" scoped>
  532. .InformationBlock{
  533. height: 100%;
  534. display: flex;
  535. flex-direction: column;
  536. overflow: hidden;
  537. >p{
  538. text-align: right;
  539. margin-top: 16px;
  540. >button:first-child{
  541. margin-right: 10px;
  542. }
  543. }
  544. .content{
  545. flex:1;
  546. display: flex;
  547. flex-direction: column;
  548. overflow: auto;
  549. .rule_content{
  550. flex: 1;
  551. overflow: auto;
  552. display: flex;
  553. flex-direction: column;
  554. .rule{
  555. flex: 1;
  556. display: flex;
  557. flex-direction: column;
  558. >.title{
  559. display: flex;
  560. align-items: center;
  561. justify-content: space-between;
  562. margin-bottom: 10px;
  563. span:first-child{
  564. font-size:14px;
  565. font-family:PingFangSC-Regular;
  566. font-weight:400;
  567. color:rgba(146,146,146,1);
  568. line-height:20px;
  569. }
  570. span:last-child{
  571. font-size:14px;
  572. font-family:PingFangSC-Regular;
  573. font-weight:400;
  574. color:rgba(16,142,233,1);
  575. line-height:20px;
  576. cursor: pointer;
  577. }
  578. }
  579. >.form{
  580. height:64px;
  581. background:rgba(255,255,255,1);
  582. border:1px solid rgba(220,222,226,1);
  583. border-bottom: 0;
  584. margin-bottom: 0;
  585. }
  586. >.ruleContent{
  587. border:1px solid rgba(220,222,226,1);
  588. overflow: auto;
  589. max-height: 100%;
  590. >.RuleConfigurationComponent{
  591. border-top:1px solid rgba(220,222,226,1);
  592. &:first-child{
  593. border-top: none;
  594. }
  595. }
  596. }
  597. }
  598. }
  599. }
  600. .form{
  601. background:rgba(255,255,255,1);
  602. border:1px solid rgba(220,222,226,1);
  603. padding: 16px 40px 16px 0;
  604. margin-bottom: 16px;
  605. >p{
  606. display: flex;
  607. align-items: center;
  608. width: 100%;
  609. margin-bottom: 10px;
  610. &:last-child{
  611. margin-bottom: 0;
  612. }
  613. >.label{
  614. display: inline-block;
  615. width: 100px;
  616. text-align: right;
  617. margin-right: 8px;
  618. .requireStyle {
  619. font-size: 14px;
  620. vertical-align: middle;
  621. color: red;
  622. padding-top: 5px;
  623. display: inline-block;
  624. }
  625. }
  626. >div{
  627. flex:1;
  628. overflow: hidden;
  629. }
  630. span.tips{
  631. font-size:12px;
  632. font-family:PingFangSC-Regular;
  633. font-weight:400;
  634. color:rgba(146,146,146,1);
  635. line-height:16px;
  636. }
  637. &.tips{
  638. margin-top: 4px;
  639. }
  640. }
  641. }
  642. }
  643. </style>