weieryang 1 год назад
Родитель
Сommit
d727deca8c

+ 14 - 0
CMS1.0/src/api/patient/patient.js

@@ -38,4 +38,18 @@ export const setLabel = (ids, label) => {
38 38
       method: 'post',
39 39
     })
40 40
 }
41
+
42
+/**
43
+ * 取消标签
44
+ */
45
+export const cancelLabel = (ids, label) => {
46
+  return request({
47
+    url: `/patient/patientlabel`,
48
+    data: {
49
+      labelName: label,
50
+      patientids: ids,
51
+    },
52
+    method: 'delete',
53
+  })
54
+}
41 55
   

+ 1 - 0
CMS1.0/src/components/page-content/src/page-content.vue

@@ -16,6 +16,7 @@
16 16
         <el-button v-if="isExport" type="primary" size="default" @click="handleExportClick">
17 17
           {{ buttons[1] }}
18 18
         </el-button>
19
+        <slot name="otherHandler"></slot>
19 20
       </template>
20 21
       <!-- 2.列中的插槽 -->
21 22
 

+ 10 - 3
CMS1.0/src/components/page-modal/src/page-modal.vue

@@ -148,9 +148,16 @@
148 148
               for (const item of props.modalConfig.formItems) {
149 149
 
150 150
                 // 时间选择器为数组,把数据转换为数组
151
-                if (item.type === 'datepicker' && item.fieldArray) {
152
-                  form[`${item.fieldArray[0]}`] = form[`${item.field}`][0]
153
-                  form[`${item.fieldArray[1]}`] = form[`${item.field}`][1]
151
+                if (item.type === 'datepicker') {
152
+
153
+                  if (item.fieldArray) {
154
+                    form[`${item.fieldArray[0]}`] = item.resFormat ? item.resFormat(form[`${item.field}`][0]) : form[`${item.field}`][0]
155
+                    form[`${item.fieldArray[1]}`] = item.resFormat ? item.resFormat(form[`${item.field}`][1]) : form[`${item.field}`][1]
156
+                  } else if (item.otherOptions.type === 'datetime' && item.resFormat) {
157
+                    form[`${item.field}`] = form[`${item.field}`] ? item.resFormat(form[`${item.field}`]) : ''
158
+                  }
159
+
160
+                
154 161
                 }
155 162
               }
156 163
 

+ 1 - 1
CMS1.0/src/utils/tools.js

@@ -10,7 +10,7 @@ export const ArrayToMap = (arr, key) => {
10 10
 }
11 11
 
12 12
 export const getTimeFrame = (starttime, endtime) => {
13
-    if (!starttime || !endtime) return '永久';
13
+    if (!starttime && !endtime) return '永久';
14 14
 
15 15
     if (starttime && !endtime) return `${starttime}以后`;
16 16
 

+ 25 - 6
CMS1.0/src/views/main/patientFile/patientFileList/patientFileList.vue

@@ -7,6 +7,10 @@
7 7
     />
8 8
     <page-content ref="pageContentRef" :contentTableConfig="contentTableConfig" pageName="/patient/patient"
9 9
       :isExport="false" @newBtnClick="handleNewData" @editBtnClick="handleEditData">
10
+      <template #otherHandler>
11
+        <el-button type="primary" @click="batchLabels(1)">批量添加标签</el-button>
12
+        <el-button type="danger" @click="batchLabels(0)">批量删除标签</el-button>
13
+      </template>
10 14
       <template #patientId="{ row }">
11 15
         <el-button type="primary" link @click="buttonHandle(row.patientId)">{{ row.name }}</el-button>
12 16
       </template>
@@ -36,7 +40,7 @@ import { useRouter } from 'vue-router';
36 40
 import PageSearch from '@/components/page-search'
37 41
 import PageContent from '@/components/page-content'
38 42
 import PageModal from '@/components/page-modal'
39
-import { setLabel } from '@/api/patient/patient';
43
+import { setLabel, cancelLabel } from '@/api/patient/patient';
40 44
 
41 45
 import { searchFormConfig } from './config/search.config'
42 46
 import { contentTableConfig } from './config/content.config'
@@ -117,11 +121,23 @@ export default defineComponent({
117 121
     })
118 122
 
119 123
 
120
-    const batchLabels = async () => {
124
+    const batchLabels = async (type) => {
125
+
126
+      const selectRows = pageContentRef.value.getSelectionRows()
127
+      if (selectRows.length <= 0) {
128
+        ElMessage({
129
+          message: '请选择要操作的数据',
130
+          type: 'warning',
131
+        })
132
+
133
+        return
134
+      }
121 135
 
136
+      const boxTitle = type ? '批量添加标签' : '批量取消标签'
137
+      const boxTip = type ? '请输入新的标签' : '请输入粘贴要取消的标签'
122 138
 
123 139
 
124
-      ElMessageBox.prompt('请输入新的标签', '批量打标签', {
140
+      ElMessageBox.prompt(boxTip, boxTitle, {
125 141
         confirmButtonText: '确定',
126 142
         cancelButtonText: '取消',
127 143
         inputPattern: /^[\w\u4E00-\u9FA5]{0,10}$/,
@@ -129,13 +145,16 @@ export default defineComponent({
129 145
       })
130 146
         .then(async ({ value }) => {
131 147
           // 获取选择的编号
132
-          const selectRows = pageContentRef.value.getSelectionRows()
133 148
 
134 149
           if (selectRows.length > 0) {
135 150
             const ids = selectRows.map((o) => o.patientId);
136 151
 
137
-            console.log(ids, 'ids');
138
-            const result = await setLabel(ids.join(','), value);
152
+            let result;
153
+            if (type === 1) {
154
+              result = await setLabel(ids, value);
155
+            } else {
156
+              result = await cancelLabel(ids, value);
157
+            }
139 158
 
140 159
             if (result.state === 'success') {
141 160
               ElMessage({

+ 36 - 6
CMS1.0/src/views/main/patientFile/patientblack/config/modal.config.js

@@ -1,3 +1,4 @@
1
+import moment from 'moment';
1 2
 export const modalConfig = {
2 3
   formItems: [
3 4
     {
@@ -7,18 +8,47 @@ export const modalConfig = {
7 8
       label: '拉黑原因',
8 9
       placeholder: '请输入拉黑原因'
9 10
     },
11
+    // {
12
+    //   field: 'timeRange',
13
+    //   type: 'datepicker',
14
+    //   label: '有效期',
15
+    //   required: false,
16
+    //   placeholder: '请选择有效期',
17
+    //   otherOptions: {
18
+    //     'range-separator': '至',
19
+    //     type: 'datetimerange',
20
+    //     'unlink-panels': true,
21
+    //     'value-format': 'YYYY-MM-DD HH:mm:ss',
22
+    //   },
23
+    //   fieldArray: ['starttime', 'endtime'],
24
+    //   resFormat: (time) => {
25
+    //     return moment(time).format('YYYY-MM-DD HH:mm:ss');
26
+    //   }
27
+    // },
10 28
     {
11
-      field: 'timeRange',
29
+      field: 'starttime',
12 30
       type: 'datepicker',
13
-      label: '有效期',
31
+      label: '开始时间',
14 32
       required: false,
15 33
       placeholder: '请选择有效期',
16 34
       otherOptions: {
17
-        'range-separator': '至',
18
-        type: 'datetimerange',
19
-        'value-format': 'YYYY-MM-DD HH:mm:ss',
35
+        type: 'datetime',
36
+        'value-format': 'yyyy-MM-dd HH:mm:ss',
37
+      },
38
+      resFormat: (time) => {
39
+        return moment(time).format('YYYY-MM-DD HH:mm:ss');
40
+      }
41
+    },
42
+    {
43
+      field: 'endtime',
44
+      type: 'datepicker',
45
+      label: '开始时间',
46
+      required: false,
47
+      placeholder: '请选择有效期',
48
+      otherOptions: {
49
+        type: 'datetime',
50
+        'value-format': 'yyyy-MM-dd HH:mm:ss',
20 51
       },
21
-      fieldArray: ['starttime', 'endtime'],
22 52
       resFormat: (time) => {
23 53
         return moment(time).format('YYYY-MM-DD HH:mm:ss');
24 54
       }