You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

445 lines
14 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="清选择导入方式"
  5. :visible.sync="dialogVisible1"
  6. width="50%"
  7. >
  8. <div class="selectby">
  9. <el-radio v-model="radio" label="1">从Excle导入</el-radio>
  10. <el-radio v-model="radio" label="2">备选项</el-radio>
  11. </div>
  12. <span slot="footer" class="dialog-footer">
  13. <el-button @click="dialogVisible1 = false"> </el-button>
  14. <el-button type="primary" @click="nextTick">下一步</el-button>
  15. </span>
  16. </el-dialog>
  17. <!-- dialog2 -->
  18. <el-dialog title="批量预登记" :visible.sync="dialogVisible2" width="50%">
  19. <div class="heading">导入EXCEL注意事项</div>
  20. <div class="mainbody">
  21. <div class="boxtitle">
  22. <div>
  23. 导入Excel时Excel的格式必须符合一定规范该格式的模板文件放在程序
  24. </div>
  25. <div>的执行目录下文件名为"单位体检人员名单导入模板.xls"</div>
  26. <div>注意事项如下:</div>
  27. <div>1:姓名不能为空其余数据可根据实际情况选择是否填写</div>
  28. <div>
  29. 2:部门单位分组性别婚姻状况人员类别体检类别民族必须与本软件
  30. </div>
  31. <div>系统中的名称完全一致</div>
  32. <div>
  33. 3:年龄和出生日期可以只填一栏系统将自动对年龄和出生日期进行相互转换
  34. </div>
  35. <div>4:Excel的实际列数不能超过20列</div>
  36. </div>
  37. </div>
  38. <span slot="footer" class="dialog-footer">
  39. <el-button @click="back2">上一步</el-button>
  40. <el-button type="primary" @click="nextstep">下一步</el-button>
  41. </span>
  42. </el-dialog>
  43. <!-- -->
  44. <el-dialog title="批量预约登记" :visible.sync="dialogVisible3" width="50%">
  45. <div class="selectfile">
  46. <div>
  47. <div><input type="file" accept=".xlsx" @change="onFileChange" /></div>
  48. <div></div>
  49. </div>
  50. </div>
  51. <span slot="footer" class="dialog-footer">
  52. <el-button @click="back3">上一步</el-button>
  53. <el-button type="primary" @click="parseImportData(startRow)"
  54. >分析</el-button
  55. >
  56. <el-button type="primary" @click="nextclick">下一步</el-button>
  57. </span>
  58. </el-dialog>
  59. <!-- 录取弹框 -->
  60. <el-dialog title="批量预登记" :visible.sync="dialogVisible5" width="50%">
  61. <span style="margin-left: 30%; font-size: 18px">选择单位</span>
  62. <div class="subheading" style="margin-top: 10px">
  63. 选择的病人必须直接属于该单位或者是该单位的一级部门,如果病人直接属于该单
  64. </div>
  65. <div class="subheading">立请将Exce1文件中该病人的部门名称设为空</div>
  66. <!-- row -->
  67. <el-row style="margin-top: 20px">
  68. <el-col :span="4" style="height: 40px; font-size: 18px">
  69. 选择单位或部门:
  70. </el-col>
  71. <el-col :span="6">
  72. <el-cascader :options="departmentdata" :show-all-levels="false" :props="{ value:'id',label: 'displayName',children: 'treeChildren'}"></el-cascader>
  73. <!-- <el-select v-model="value" placeholder="请选择" @change="onchange">
  74. <el-option
  75. v-for="item in departmentdata"
  76. :key="item.id"
  77. :label="item.displayName"
  78. :value="item.id"
  79. >
  80. </el-option>
  81. </el-select> -->
  82. </el-col>
  83. <el-col :span="4" style="line-height: 40px; font-size: 18px"
  84. >单位设置</el-col
  85. >
  86. </el-row>
  87. <!-- row -->
  88. <div style="width: 100%">
  89. <div style="margin-top:10px;margin">
  90. 相同姓名的病人
  91. <el-radio-group v-model="nameType" @input="splices">
  92. <el-radio label="同名病人提示">同名病人提示</el-radio>
  93. <el-radio label="仅本单位同名病人提示"
  94. >仅本单位同名病人提示</el-radio
  95. >
  96. <el-radio label="不提示">不提示</el-radio>
  97. </el-radio-group>
  98. </div>
  99. </div>
  100. <div style="margin-top: 10px; margin-left: 10px">
  101. 登记状态
  102. <el-radio-group v-model="nameType">
  103. <el-radio label="预登记">预登记</el-radio>
  104. <el-radio label="仅本单位同名病人提示">仅本单位同名病人提示</el-radio>
  105. </el-radio-group>
  106. </div>
  107. <div style="margin-top: 10px">
  108. <div>工卡号</div>
  109. <div style="margin-top: 5px">
  110. <el-checkbox v-model="checked">工卡号作为档案号</el-checkbox>
  111. </div>
  112. </div>
  113. <div>
  114. <span>工卡号开始位置</span>
  115. <el-input
  116. v-model="input"
  117. placeholder="请输入内容"
  118. type="number"
  119. style="width: 20%; margin-left: 10px"
  120. ></el-input>
  121. 长度
  122. <el-input
  123. v-model="form.cardLength"
  124. placeholder="请输入内容"
  125. type="number"
  126. style="width: 20%; margin-left: 10px"
  127. ></el-input>
  128. </div>
  129. <div style="margin-top: 10px">
  130. <el-checkbox v-model="form.isAutoCreateDepartment" @change="createornot"
  131. >自动创建部门</el-checkbox
  132. >
  133. </div>
  134. <span slot="footer" class="dialog-footer">
  135. <el-button @click="dialogVisible5 = false"> </el-button>
  136. <el-button type="primary" @click="submitto"> </el-button>
  137. </span>
  138. </el-dialog>
  139. <!-- -->
  140. <!--dialogVisible4 -->
  141. <el-dialog title="批量预约登记" :visible.sync="dialogVisible4" width="50%">
  142. <el-table
  143. :data="tableData"
  144. @row-click="rowclick"
  145. style="width: 100%"
  146. height="300px"
  147. highlight-current-row
  148. ref="singleTable"
  149. >
  150. <el-table-column
  151. v-for="(item, index) in tableDataCol"
  152. :key="index"
  153. :prop="item.excelCol"
  154. :label="item.label"
  155. />
  156. </el-table>
  157. <div style="margin-top: 20px">
  158. <div v-for="(item, index) in tableData" :key="index"></div>
  159. <el-button @click="setCurrent(tableData[0])">全选</el-button>
  160. <el-button @click="setCurrent()">取消选择</el-button>
  161. </div>
  162. <span slot="footer" class="dialog-footer">
  163. <el-button @click="dialogVisible4 = false">上一步</el-button>
  164. <el-button @click="back4">上一步</el-button>
  165. <el-button type="primary" @click="tablenext">下一步</el-button>
  166. </span>
  167. </el-dialog>
  168. <!-- -->
  169. </div>
  170. </template>
  171. <script>
  172. import ExcelJS from "exceljs";
  173. import { postapi, getapi } from "@/api/api";
  174. export default {
  175. data() {
  176. return {
  177. checked: "",
  178. input: "",
  179. form: {
  180. nameType: "",
  181. cardLength: "",
  182. isAutoCreateDepartment: "N", //
  183. customerOrgId: "", //单位id
  184. isAutoCreatePatientNo: "N",
  185. cardStartNum: "0",
  186. patientName: "",
  187. },
  188. value: "",
  189. nameType: "1",
  190. currentRow: null,
  191. radio: "1",
  192. dialogVisible1: true,
  193. dialogVisible2: false,
  194. dialogVisible3: false,
  195. dialogVisible4: false,
  196. dialogVisible5: false,
  197. startRow: 2, //数据开始行,标题行为 startRow - 1 ;
  198. importData: [], //导入原始数据
  199. tableDataCol: [], //导入原始数据 {excelCol,apiCol,label}
  200. tableData: [], //导入原始数据 分析后 表格数据
  201. formrow: {},
  202. departmentdata: [], //单位分组
  203. };
  204. },
  205. methods: {
  206. submitto() {
  207. if (this.form.customerOrgId == undefined) {
  208. this.$message.warning("请选择单位");
  209. } else {
  210. this.form= Object.assign(this.form,this.formrow)
  211. postapi(
  212. "/api/app/patientregister/createpatientregisterexcel",
  213. this.form
  214. ).then((res) => {
  215. if (res.code == 1) {
  216. this.$message.success(res.data.msg);
  217. }
  218. console.log(res);
  219. });
  220. console.log(this.form);
  221. }
  222. console.log(this.form.customerOrgId);
  223. },
  224. onchange(id) {
  225. this.form.customerOrgId = id;
  226. console.log(id);
  227. },
  228. splices() {
  229. if (this.nameType == 1) {
  230. this.nameType = "同名病人提示";
  231. }
  232. console.log(this.nameType);
  233. },
  234. //是否创建
  235. createornot() {
  236. if (this.form.isAutoCreateDepartment == true) {
  237. this.form.isAutoCreateDepartment = "Y";
  238. } else {
  239. this.form.isAutoCreateDepartment = "N";
  240. console.log("1");
  241. }
  242. console.log(this.form.isAutoCreateDepartment);
  243. },
  244. slicetdata() {
  245. console.log("2");
  246. getapi("/api/app/customer-org/by-code-all").then((res) => {
  247. this.departmentdata = res.data;
  248. console.log(res);
  249. });
  250. },
  251. tablenext() {
  252. if (JSON.stringify(this.formrow) == "{}") {
  253. this.$message.warning("请选择数据");
  254. } else {
  255. this.form = this.formrow;
  256. this.dialogVisible5 = true;
  257. this.dialogVisible4 = false;
  258. this.slicetdata();
  259. }
  260. },
  261. determine() {
  262. if (JSON.stringify(this.formrow) == "{}") {
  263. this.$message.warning("请选择数据");
  264. } else {
  265. this.dialogVisible5 = true;
  266. this.dialogVisible4 = false;
  267. }
  268. },
  269. rowclick(row) {
  270. // console.log(row);
  271. this.form.patientName = row.姓名;
  272. this.form.sexName = row.性别;
  273. this.form.idNo = row.证件号码;
  274. this.formrow = row;
  275. // this.form.birthDate = row.this.formrow = row;
  276. // console.log(this.formrow);
  277. },
  278. aa() {
  279. console.log("1");
  280. },
  281. setCurrent(row) {
  282. console.log(row);
  283. this.$refs.singleTable.setCurrentRow(row);
  284. console.log(row, column, "event", "cell");
  285. console.log(this.$refs.singleTable);
  286. },
  287. handleCurrentChange(val) {
  288. this.currentRow = val;
  289. },
  290. onFileChange(event) {
  291. // 获取上传的文件
  292. const file = event.target.files[0];
  293. // 调用导入Excel文件的方法
  294. this.importExcelFile(file);
  295. this.parseImportData();
  296. },
  297. importExcelFile(file) {
  298. this.filepopupdialogVisible = true;
  299. console.log("333");
  300. // 创建一个工作簿
  301. const workbook = new ExcelJS.Workbook();
  302. // 读取Excel文件
  303. const reader = new FileReader();
  304. console.log(reader);
  305. reader.onload = () => {
  306. const buffer = reader.result;
  307. const typedArray = new Uint8Array(buffer);
  308. const blob = new Blob([typedArray], {
  309. type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
  310. });
  311. // 从Blob中读取Excel文件
  312. workbook.xlsx.load(blob).then((workbook) => {
  313. // 获取第一个工作表
  314. const worksheet = workbook.getWorksheet(1);
  315. // 处理Excel文件内容
  316. worksheet.eachRow((row, rowNumber) => {
  317. console.log(row.values);
  318. this.importData.push(row.values);
  319. // console.log(`第${row.rowNumber}行的数据:${row.rowData}`);
  320. });
  321. });
  322. };
  323. reader.readAsArrayBuffer(file);
  324. },
  325. //导入后数据分析
  326. parseImportData(startRow) {
  327. if (!this.importData || this.importData.length == 0) return;
  328. let cols = [];
  329. let record = {};
  330. this.importData.forEach((item, index) => {
  331. console.log(index, item);
  332. if (index == startRow - 2) {
  333. item.forEach((e, i) => {
  334. console.log("e", i, e);
  335. if (i > 0) {
  336. if (e) {
  337. this.tableDataCol.push({ excelCol: e, apiCol: "", label: e });
  338. cols.push(e);
  339. } else {
  340. this.tableDataCol.push({
  341. excelCol: `${Number(i) + 1}`,
  342. apiCol: "",
  343. lebel: `${Number(i) + 1}`,
  344. });
  345. cols.push(`${Number(i) + 1}`);
  346. }
  347. }
  348. });
  349. } else if (index > startRow - 2) {
  350. for (let i = 0; i < item.length; i++) {
  351. if (i > 0) {
  352. console.log("cols[i]", i, cols[i - 1]);
  353. if (item[i]) {
  354. record[cols[i - 1]] = item[i];
  355. } else {
  356. record[cols[i - 1]] = null;
  357. }
  358. }
  359. }
  360. this.tableData.push({ ...record });
  361. }
  362. });
  363. console.log("tableDataCol", this.tableDataCol);
  364. console.log("tableData", this.tableData);
  365. },
  366. nextclick() {
  367. if (this.tableData.length > 1) {
  368. console.log("1");
  369. this.dialogVisible4 = true;
  370. this.dialogVisible3 = false;
  371. //支付方式
  372. getapi("/api/app/pay-mode").then((res) => {
  373. this.paymodedata = res.data;
  374. });
  375. //婚姻状况
  376. getapi("/api/app/marital-statuses").then((res) => {
  377. this.maritalstatusesdata = res.data;
  378. console.log(res);
  379. });
  380. //团检登记
  381. getapi("/api/app/customer-org-register/in-filter").then((res) => {
  382. console.log(res);
  383. });
  384. } else {
  385. this.$message.warning("请选择导入的文件并解析");
  386. }
  387. console.log(this.tableData);
  388. },
  389. nextTick() {
  390. if (this.radio == 1) {
  391. this.dialogVisible1 = false;
  392. this.dialogVisible2 = true;
  393. }
  394. console.log(this.radio);
  395. },
  396. back4() {
  397. this.dialogVisible4 = false;
  398. this.dialogVisible3 = true;
  399. },
  400. back3() {
  401. this.dialogVisible3 = false;
  402. this.dialogVisible2 = true;
  403. },
  404. // 上一步
  405. back2() {
  406. this.dialogVisible2 = false;
  407. this.dialogVisible1 = true;
  408. },
  409. //下一步
  410. nextstep() {
  411. this.dialogVisible3 = true;
  412. this.dialogVisible2 = false;
  413. },
  414. loading() {},
  415. },
  416. };
  417. </script>
  418. <style scoped>
  419. .subheading {
  420. margin-left: 10%;
  421. }
  422. .selectfile {
  423. display: flex;
  424. }
  425. .boxtitle {
  426. margin-left: 25%;
  427. margin-top: 20px;
  428. }
  429. .mainbody {
  430. width: 100%;
  431. }
  432. .heading {
  433. text-align: center;
  434. font-size: 18px;
  435. }
  436. .selectby {
  437. display: flex;
  438. justify-content: center;
  439. }
  440. </style>