inl-ui 0.0.19 → 0.0.21

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.
@@ -9,11 +9,13 @@
9
9
  import { computed, defineComponent, inject, ref, watch } from "vue";
10
10
  import useTableList from "@/pageComponent/hooks/useTableList";
11
11
  import useModalVisibleControl from "@/pageComponent/hooks/manage-module/useModalVisibleControl";
12
+ import dayjs from "dayjs";
12
13
  import api from "@/api/org/depManager";
13
14
  import { IUrlObj } from "./index";
14
15
 
15
16
  import { Modal } from "ant-design-vue";
16
17
  import UpdateEmployeeDialog from "./updateEmployeeDialog";
18
+ import BatchImportModal from "./batchImportModal";
17
19
 
18
20
  const columns = [
19
21
  {
@@ -130,9 +132,27 @@ const EmployeeTable = defineComponent({
130
132
  refresh();
131
133
  };
132
134
 
135
+ // 批量导入/导出
136
+ const [isImportDialogShow, handleImportClick] = useModalVisibleControl();
137
+
138
+ const selectIdList = ref<string[]>([]);
139
+ watch(
140
+ () => props.depId,
141
+ () => (selectIdList.value = [])
142
+ );
143
+ const handleSelect = (selectedRowKeys: string[]) => {
144
+ selectIdList.value = selectedRowKeys;
145
+ };
146
+ const handleExport = () => {
147
+ const day = dayjs();
148
+ const aEl = document.createElement("a");
149
+ aEl.href = "/api/common/v1/employee/export/multi";
150
+ aEl.download = `批量导出成员_${day.format("YYYY_M_D_ms")}`;
151
+ aEl.click();
152
+ };
153
+
133
154
  return () => (
134
155
  <div class="employee-table">
135
- <h2 class="部门人员详情"></h2>
136
156
  <div class="operation">
137
157
  <a-space>
138
158
  <a-button
@@ -142,6 +162,13 @@ const EmployeeTable = defineComponent({
142
162
  >
143
163
  新建
144
164
  </a-button>
165
+ <a-button onClick={handleImportClick}>批量导入</a-button>
166
+ <a-button
167
+ disabled={!selectIdList.value.length}
168
+ onClick={handleExport}
169
+ >
170
+ 批量导出
171
+ </a-button>
145
172
  </a-space>
146
173
  <a-input
147
174
  style={{ width: "200px" }}
@@ -153,9 +180,14 @@ const EmployeeTable = defineComponent({
153
180
  />
154
181
  </div>
155
182
  <a-table
183
+ rowKey="id"
156
184
  loading={isLoading.value}
157
185
  columns={columns}
158
186
  dataSource={tableList.value}
187
+ rowSelection={{
188
+ selectedRowKeys: selectIdList.value,
189
+ onChange: handleSelect,
190
+ }}
159
191
  pagination={{
160
192
  pageSize: pageSize.value,
161
193
  current: currPage.value,
@@ -218,6 +250,11 @@ const EmployeeTable = defineComponent({
218
250
  v-model={[isEditDialogShow.value, "visible"]}
219
251
  onRefresh={refresh}
220
252
  />
253
+
254
+ <BatchImportModal
255
+ v-model={[isImportDialogShow.value, "visible"]}
256
+ onRefresh={refresh}
257
+ />
221
258
  </div>
222
259
  );
223
260
  },
@@ -114,14 +114,25 @@ const com = defineComponent({
114
114
  const { file, onSuccess, onError } = options;
115
115
  const fileData = new FormData();
116
116
  fileData.append("file", file as any);
117
- const res: any = await modelApis.importExcel(fileData);
118
- if (res.code === "M0000") {
119
- message.success("上传成功");
120
- onSuccess("response", file);
121
- } else {
122
- message.error("上传失败");
123
- onError("error", file);
124
- }
117
+ const hide = message.info({
118
+ duration: 0,
119
+ content: "正在导入,请稍后",
120
+ });
121
+ modelApis
122
+ .importExcel(fileData)
123
+ .then((res) => {
124
+ if (res.data === true) {
125
+ message.success("导入成功");
126
+ onSuccess("response", file);
127
+ } else {
128
+ message.error("导入失败");
129
+ onError("error", file);
130
+ downFile(res.data, "错误信息.txt");
131
+ }
132
+ })
133
+ .finally(() => {
134
+ hide();
135
+ });
125
136
  };
126
137
  const exportFun = async () => {
127
138
  message.info({
@@ -129,19 +140,39 @@ const com = defineComponent({
129
140
  content: "正在导出,请稍后",
130
141
  });
131
142
  const res: any = await modelApis.exportExcelTemplate();
143
+ downFile(
144
+ res,
145
+ "物模型数据_" + moment().format("YYYY_MM_DD_HHmm") + ".xls"
146
+ );
147
+ setTimeout(() => {
148
+ message.destroy();
149
+ }, 666);
150
+ };
151
+ const downFun = async () => {
152
+ message.info({
153
+ duration: 0,
154
+ content: "正在下载,请稍后",
155
+ });
156
+ const res: any = await modelApis.downExcelTemplate();
157
+ downFile(
158
+ res,
159
+ "【模板】物模型数据_" + moment().format("YYYY_MM_DD_HHmm") + ".xls"
160
+ );
161
+ setTimeout(() => {
162
+ message.destroy();
163
+ }, 666);
164
+ };
165
+ const downFile = (res: any, filename: string) => {
132
166
  const blob = new Blob([res], {
133
167
  type: "text/html;charset=UTF-8",
134
168
  });
135
169
  const a = document.createElement("a");
136
170
  a.href = URL.createObjectURL(blob);
137
- a.download = "物模型数据-" + moment().format("YYYYMMDDHHmmss") + ".xls";
171
+ a.download = filename;
138
172
  a.style.display = "none";
139
173
  document.body.appendChild(a);
140
174
  a.click();
141
175
  a.remove();
142
- setTimeout(() => {
143
- message.destroy();
144
- }, 666);
145
176
  };
146
177
  const openModal = () => {
147
178
  updateModalRef.value.open(true);
@@ -252,6 +283,15 @@ const com = defineComponent({
252
283
  >
253
284
  导出全部
254
285
  </a-button>
286
+ <a-button
287
+ type="primary"
288
+ onClick={() => {
289
+ downFun();
290
+ }}
291
+ ghost
292
+ >
293
+ 下载模板
294
+ </a-button>
255
295
  </a-space>
256
296
  {/* row-selection={{
257
297
  selectedRowKeys: state.selectedRowKeys,