@lambo-design/workflow-approve 1.0.0-beta.140 → 1.0.0-beta.141

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambo-design/workflow-approve",
3
- "version": "1.0.0-beta.140",
3
+ "version": "1.0.0-beta.141",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
@@ -361,6 +361,59 @@
361
361
  <Modal title="查看附件" v-model="modalDocx" fullscreen scrollable :mask="false">
362
362
  <div ref="file"></div>
363
363
  </Modal>
364
+ <Modal
365
+ v-model="remindModalVisible"
366
+ title="催办提醒"
367
+ width="640"
368
+ class-name="todo-remind-modal"
369
+ @on-cancel="closeRemindModal"
370
+ >
371
+ <div class="todo-remind-dialog">
372
+ <div class="todo-remind-row">
373
+ <div class="todo-remind-label">催办类型:</div>
374
+ <CheckboxGroup v-model="remindForm.types" class="todo-remind-type-group">
375
+ <Checkbox label="MESSAGE">系统消息</Checkbox>
376
+ <Checkbox label="SMS">短信提醒</Checkbox>
377
+ </CheckboxGroup>
378
+ </div>
379
+ <div class="todo-remind-row todo-remind-row-top">
380
+ <div class="todo-remind-label">催办内容:</div>
381
+ <div class="todo-remind-body">
382
+ <Input
383
+ ref="remindContent"
384
+ v-model="remindForm.content"
385
+ type="textarea"
386
+ :rows="6"
387
+ :maxlength="500"
388
+ show-word-limit
389
+ placeholder="请输入催办内容"
390
+ class="todo-remind-textarea"
391
+ @on-focus="syncRemindCursor"
392
+ @on-click="syncRemindCursor"
393
+ @on-keyup="syncRemindCursor"
394
+ @on-select="syncRemindCursor"
395
+ />
396
+ </div>
397
+ </div>
398
+ <div class="todo-remind-row todo-remind-row-top">
399
+ <div class="todo-remind-label">占位变量:</div>
400
+ <div class="todo-remind-body todo-remind-variable-list">
401
+ <button
402
+ v-for="item in remindVariableList"
403
+ :key="item.key"
404
+ type="button"
405
+ class="todo-remind-variable"
406
+ @mousedown.prevent="insertRemindVariable(item)"
407
+ >
408
+ {{ item.label }}
409
+ </button>
410
+ </div>
411
+ </div>
412
+ </div>
413
+ <template #footer>
414
+ <Button type="primary" :loading="remindSubmitting" @click="submitRemind">催办</Button>
415
+ </template>
416
+ </Modal>
364
417
  </div>
365
418
  </template>
366
419
 
@@ -425,6 +478,53 @@ export default {
425
478
  itemList: [],
426
479
  auditNameList: [],
427
480
  displayPushButton: false,
481
+ remindModalVisible: false,
482
+ remindSubmitting: false,
483
+ currentRemindRow: null,
484
+ remindCursorStart: 0,
485
+ remindCursorEnd: 0,
486
+ remindForm: {
487
+ types: ['MESSAGE'],
488
+ content: ''
489
+ },
490
+ remindVariableList: [
491
+ {
492
+ key: 'applyId',
493
+ label: '申请编码'
494
+ },
495
+ {
496
+ key: 'applyUserName',
497
+ label: '发起人'
498
+ },
499
+ {
500
+ key: 'procName',
501
+ label: '流程名称'
502
+ },
503
+ {
504
+ key: 'procTypeName',
505
+ label: '流程类型'
506
+ },
507
+ {
508
+ key: 'startTime',
509
+ label: '发起时间'
510
+ },
511
+ {
512
+ key: 'businessTopic',
513
+ label: '业务主题'
514
+ },
515
+ {
516
+ key: 'busKeyDes',
517
+ label: '业务描述'
518
+ },
519
+ {
520
+ key: 'taskName',
521
+ label: '环节名称'
522
+ },
523
+ {
524
+ key: 'orgName',
525
+ label: '区域名称'
526
+ }
527
+ ],
428
528
  sortBy: this.historySortBy,
429
529
  pendingActiveName: [], // 控制待审批折叠面板的展开状态
430
530
  }
@@ -602,37 +702,142 @@ export default {
602
702
  },
603
703
  methods: {
604
704
  pushHim(item, auditName, index) {
605
- if (this.isDebouncing) {
606
- return;
705
+ this.openRemindModal(item, auditName, index)
706
+ },
707
+ getRemindContextRow(item, auditName, index) {
708
+ const applyUser = item && item.applyUser ? String(item.applyUser) : ''
709
+ const applyUserName = applyUser && applyUser.indexOf(':') > -1 ? applyUser.split(':')[1] : applyUser
710
+ const auditIds = item && item.auditId
711
+ const auditId = Array.isArray(auditIds) ? auditIds[index] : auditIds
712
+ return Object.assign({}, item, {
713
+ applyUserName,
714
+ auditName,
715
+ auditId,
716
+ startTime: this.formatDateTime(item && item.startDate),
717
+ procInstanceId: item && (item.procInstanceId || item.instanceId) ? (item.procInstanceId || item.instanceId) : ''
718
+ })
719
+ },
720
+ openRemindModal(item, auditName, index) {
721
+ this.currentRemindRow = this.getRemindContextRow(item || {}, auditName, index)
722
+ this.remindModalVisible = true
723
+ },
724
+ closeRemindModal() {
725
+ this.remindModalVisible = false
726
+ this.$nextTick(() => {
727
+ this.resetRemindForm()
728
+ })
729
+ },
730
+ resetRemindForm() {
731
+ this.currentRemindRow = null
732
+ this.remindCursorStart = 0
733
+ this.remindCursorEnd = 0
734
+ this.remindSubmitting = false
735
+ this.remindForm = {
736
+ types: ['MESSAGE'],
737
+ content: ''
607
738
  }
608
-
609
- this.isDebouncing = true;
610
- // 设置一个延时,例如 1 秒,之后重置防抖状态
611
- setTimeout(() => {
612
- this.isDebouncing = false;
613
- }, 2000);
614
-
615
- let self = this;
616
- let applyUserName = item.applyUser.split(":")[1];
617
- let params = {
618
- applyUserName: applyUserName,
619
- auditName: auditName,
620
- auditId: item.auditId[index],
621
- procName: item.procName,
622
- effectTime: item.startDate,
623
- expireTime: item.warningDate,
624
- applyId: item.applyId,
625
- taskNode: item.taskNode
626
- };
627
- let url = self.smartFlowServerContext + "/manage/processTodo/sendMessage";
628
- ajax.post(url, params).then(function (resp) {
629
- console.log("message ", resp);
630
- if (resp.data.code == 200) {
631
- self.$Message.success("催办成功");
632
- } else {
633
- self.$Message.error("催办失败");
739
+ },
740
+ syncRemindCursor() {
741
+ this.$nextTick(() => {
742
+ const inputRef = this.$refs.remindContent
743
+ const textarea = inputRef && inputRef.$refs ? inputRef.$refs.textarea : null
744
+ if (!textarea) {
745
+ return
634
746
  }
635
- });
747
+ this.remindCursorStart = typeof textarea.selectionStart === 'number' ? textarea.selectionStart : 0
748
+ this.remindCursorEnd = typeof textarea.selectionEnd === 'number' ? textarea.selectionEnd : this.remindCursorStart
749
+ })
750
+ },
751
+ insertRemindVariable(variable) {
752
+ const key = variable && variable.key ? variable.key : ''
753
+ const rawValue = key && this.currentRemindRow ? this.currentRemindRow[key] : ''
754
+ const value = rawValue === null || rawValue === undefined || rawValue === '--' ? '' : String(rawValue)
755
+ if (!value) {
756
+ return
757
+ }
758
+ const currentContent = this.remindForm.content || ''
759
+ const inputRef = this.$refs.remindContent
760
+ const textarea = inputRef && inputRef.$refs ? inputRef.$refs.textarea : null
761
+ const selectionStart = textarea && typeof textarea.selectionStart === 'number' ? textarea.selectionStart : this.remindCursorStart
762
+ const selectionEnd = textarea && typeof textarea.selectionEnd === 'number' ? textarea.selectionEnd : this.remindCursorEnd
763
+ const start = Math.max(0, Math.min(selectionStart, currentContent.length))
764
+ const end = Math.max(start, Math.min(selectionEnd, currentContent.length))
765
+ this.remindForm.content = `${currentContent.slice(0, start)}${value}${currentContent.slice(end)}`
766
+ this.$nextTick(() => {
767
+ const currentInputRef = this.$refs.remindContent
768
+ const currentTextarea = currentInputRef && currentInputRef.$refs ? currentInputRef.$refs.textarea : null
769
+ if (currentTextarea && typeof currentTextarea.focus === 'function') {
770
+ currentTextarea.focus()
771
+ const nextPosition = start + value.length
772
+ if (typeof currentTextarea.setSelectionRange === 'function') {
773
+ currentTextarea.setSelectionRange(nextPosition, nextPosition)
774
+ }
775
+ this.remindCursorStart = nextPosition
776
+ this.remindCursorEnd = nextPosition
777
+ }
778
+ })
779
+ },
780
+ submitRemind() {
781
+ if (this.remindSubmitting) {
782
+ return
783
+ }
784
+ if (!this.remindForm.types.length) {
785
+ this.$Message.warning('请选择至少一种催办类型')
786
+ return
787
+ }
788
+ const messageContent = (this.remindForm.content || '').trim()
789
+ if (!messageContent) {
790
+ this.$Message.warning('请输入催办内容')
791
+ return
792
+ }
793
+ const remindRow = this.currentRemindRow || {}
794
+ const taskNode = remindRow.taskNode
795
+ const procInstanceId = remindRow.procInstanceId
796
+ if (!taskNode || !procInstanceId) {
797
+ this.$Message.error('催办参数缺失,无法提交')
798
+ return
799
+ }
800
+ const actionTypes = this.remindForm.types.filter(Boolean)
801
+ if (!actionTypes.length) {
802
+ this.$Message.error('催办类型转换失败')
803
+ return
804
+ }
805
+ const requestUrl = this.smartFlowServerContext + '/manage/processTodo/urgeTask'
806
+ const actionType = actionTypes.join(',')
807
+ this.remindSubmitting = true
808
+ this.$Spin.show()
809
+ ajax.post(requestUrl, { taskNode, procInstanceId, actionType, messageContent }).then((resp) => {
810
+ const successCodes = ['200', 200]
811
+ if (!resp || !resp.data || successCodes.indexOf(resp.data.code) === -1) {
812
+ const message = resp && resp.data && resp.data.message ? resp.data.message : '催办失败'
813
+ this.$Message.error(message)
814
+ this.closeRemindModal()
815
+ return
816
+ }
817
+ this.$Message.success('催办成功')
818
+ this.closeRemindModal()
819
+ }).catch(() => {
820
+ this.$Message.error('催办失败')
821
+ }).finally(() => {
822
+ this.remindSubmitting = false
823
+ this.$Spin.hide()
824
+ })
825
+ },
826
+ formatDateTime(value) {
827
+ if (!value) {
828
+ return '--'
829
+ }
830
+ const date = new Date(value)
831
+ if (Number.isNaN(date.getTime())) {
832
+ return '--'
833
+ }
834
+ const year = date.getFullYear()
835
+ const month = String(date.getMonth() + 1).padStart(2, '0')
836
+ const day = String(date.getDate()).padStart(2, '0')
837
+ const hours = String(date.getHours()).padStart(2, '0')
838
+ const minutes = String(date.getMinutes()).padStart(2, '0')
839
+ const seconds = String(date.getSeconds()).padStart(2, '0')
840
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
636
841
  },
637
842
  getAttach(row) {
638
843
  window.open(this.smartFlowServerContext + "/manage/oss/file/get/" + row.fileId, "_blank");
@@ -890,4 +1095,87 @@ export default {
890
1095
  padding: 5px !important;
891
1096
  }
892
1097
 
1098
+ .todo-remind-dialog {
1099
+ padding: 8px 8px 0;
1100
+ }
1101
+
1102
+ .todo-remind-row {
1103
+ display: flex;
1104
+ align-items: center;
1105
+ margin-bottom: 20px;
1106
+ }
1107
+
1108
+ .todo-remind-row-top {
1109
+ align-items: flex-start;
1110
+ }
1111
+
1112
+ .todo-remind-label {
1113
+ width: 96px;
1114
+ flex-shrink: 0;
1115
+ color: #17233d;
1116
+ line-height: 32px;
1117
+ text-align: right;
1118
+ }
1119
+
1120
+ .todo-remind-body {
1121
+ flex: 1;
1122
+ min-width: 0;
1123
+ }
1124
+
1125
+ .todo-remind-type-group {
1126
+ display: flex;
1127
+ align-items: center;
1128
+ flex-wrap: wrap;
1129
+ gap: 20px;
1130
+ min-height: 32px;
1131
+ }
1132
+
1133
+ .todo-remind-type-group .ivu-checkbox-wrapper {
1134
+ margin-right: 0;
1135
+ }
1136
+
1137
+ .todo-remind-textarea textarea {
1138
+ resize: none;
1139
+ min-height: 132px;
1140
+ }
1141
+
1142
+ .todo-remind-variable-list {
1143
+ display: flex;
1144
+ flex-wrap: wrap;
1145
+ gap: 12px;
1146
+ }
1147
+
1148
+ .todo-remind-variable {
1149
+ min-width: 72px;
1150
+ height: 28px;
1151
+ padding: 0 10px;
1152
+ border: 1px solid #dcdfe6;
1153
+ border-radius: 4px;
1154
+ background: #fff;
1155
+ color: #515a6e;
1156
+ cursor: pointer;
1157
+ transition: all 0.2s ease;
1158
+ font-size: 12px;
1159
+ line-height: 28px;
1160
+ }
1161
+
1162
+ .todo-remind-variable:hover {
1163
+ color: #2d8cf0;
1164
+ border-color: #2d8cf0;
1165
+ background: #f0faff;
1166
+ }
1167
+
1168
+ .todo-remind-modal .ivu-modal-header {
1169
+ padding: 16px 24px;
1170
+ }
1171
+
1172
+ .todo-remind-modal .ivu-modal-body {
1173
+ padding: 20px 24px 12px;
1174
+ }
1175
+
1176
+ .todo-remind-modal .ivu-modal-footer {
1177
+ padding: 10px 24px 20px;
1178
+ border-top: none;
1179
+ }
1180
+
893
1181
  </style>