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.

626 lines
19 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
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
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
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
  73. @change="onchange"
  74. v-model="form.customerOrgId"
  75. :options="departmentdata"
  76. :props="{
  77. checkStrictly: true,
  78. value: 'id',
  79. label: 'displayName',
  80. children: 'treeChildren',
  81. }"
  82. ></el-cascader>
  83. <!-- <el-select v-model="value" placeholder="请选择" @change="onchange">
  84. <el-option
  85. v-for="item in departmentdata"
  86. :key="item.id"
  87. :label="item.displayName"
  88. :value="item.id"
  89. >
  90. </el-option>
  91. </el-select> -->
  92. </el-col>
  93. <el-col :span="4" style="line-height: 40px; font-size: 18px"
  94. >单位设置</el-col
  95. >
  96. </el-row>
  97. <!-- 是否为体检中心 -->
  98. <el-row>
  99. <el-col :span="4">
  100. <span style="height: 40px; font-size: 18px">体检中心</span>
  101. </el-col>
  102. <el-col :span="8">
  103. <el-select v-model="form.organizationUnitId" placeholder="请选择">
  104. <el-option
  105. v-for="item in examinatioitems"
  106. :key="item.id"
  107. :label="item.displayName"
  108. :value="item.id"
  109. >
  110. </el-option>
  111. </el-select>
  112. </el-col>
  113. </el-row>
  114. <!-- row -->
  115. <div style="width: 100%">
  116. <div style="margin-top:10px;margin">
  117. 相同姓名的病人
  118. <el-radio-group v-model="nameType" @input="splices">
  119. <el-radio label="同名病人提示">同名病人提示</el-radio>
  120. <el-radio label="仅本单位同名病人提示"
  121. >仅本单位同名病人提示</el-radio
  122. >
  123. <el-radio label="不提示">不提示</el-radio>
  124. </el-radio-group>
  125. </div>
  126. </div>
  127. <div style="margin-top: 10px; margin-left: 10px">
  128. 登记状态
  129. <el-radio-group v-model="form.nameType">
  130. <el-radio label="Y">预登记</el-radio>
  131. <el-radio label="N">正式登记</el-radio>
  132. </el-radio-group>
  133. </div>
  134. <div style="margin-top: 10px">
  135. <div>工卡号</div>
  136. <div style="margin-top: 5px">
  137. <el-checkbox v-model="checked">工卡号作为档案号</el-checkbox>
  138. </div>
  139. </div>
  140. <div>
  141. <span>工卡号开始位置</span>
  142. <el-input
  143. v-model="input"
  144. placeholder="请输入内容"
  145. type="number"
  146. style="width: 20%; margin-left: 10px"
  147. ></el-input>
  148. 长度
  149. <el-input
  150. v-model="form.cardLength"
  151. placeholder="请输入内容"
  152. type="number"
  153. style="width: 20%; margin-left: 10px"
  154. ></el-input>
  155. </div>
  156. <div style="margin-top: 10px">
  157. 自动创建部门
  158. <el-radio-group v-model="form.isAutoCreateDepartment">
  159. <el-radio label="Y"></el-radio>
  160. <el-radio label="N"></el-radio>
  161. </el-radio-group>
  162. <!-- <el-checkbox v-model="form.isAutoCreateDepartment" @change="createornot"
  163. >自动创建部门</el-checkbox
  164. > -->
  165. </div>
  166. <el-progress
  167. :text-inside="true"
  168. :stroke-width="26"
  169. :percentage="100"
  170. v-if="percentage"
  171. ></el-progress>
  172. <span slot="footer" class="dialog-footer">
  173. <el-button @click="dialogVisible5 = false"> </el-button>
  174. <el-button type="primary" @click="submitBatch"> </el-button>
  175. </span>
  176. </el-dialog>
  177. <!-- -->
  178. <!--dialogVisible4 -->
  179. <el-dialog title="批量预约登记" :visible.sync="dialogVisible4" width="50%">
  180. <el-table
  181. :data="tableData"
  182. @row-click="rowclick"
  183. style="width: 100%"
  184. height="300px"
  185. highlight-current-row
  186. ref="singleTable"
  187. @header-click="colcliick(item.label)"
  188. >
  189. <el-table-column
  190. v-for="(item, index) in tableDataCol"
  191. :key="index"
  192. :prop="item.excelCol"
  193. :label="item.label"
  194. />
  195. </el-table>
  196. <div style="margin-top: 20px">
  197. <div v-for="(item, index) in tableData" :key="index"></div>
  198. <el-button @click="setCurrent(tableData)">全选</el-button>
  199. <el-button @click="setCurrents()">取消选择</el-button>
  200. </div>
  201. <span slot="footer" class="dialog-footer">
  202. <!-- <el-button @click="dialogVisible4 = false">上一步</el-button> -->
  203. <el-button @click="back4">上一步</el-button>
  204. <el-button type="primary" @click="tablenext">下一步</el-button>
  205. </span>
  206. </el-dialog>
  207. <!-- -->
  208. <!-- dialogVisible6 -->
  209. <el-dialog
  210. title="批量预约登记提示"
  211. :visible.sync="dialogVisible6"
  212. width="50%"
  213. >
  214. <div>
  215. <div>成功导入的数据</div>
  216. {{ object }}
  217. 姓名 {{ object.姓名 }}
  218. </div>
  219. <span slot="footer" class="dialog-footer">
  220. <el-button @click="dialogVisible6 = false"> </el-button>
  221. <el-button type="primary" @click="dialogVisible6 = false"
  222. > </el-button
  223. >
  224. </span>
  225. </el-dialog>
  226. <!-- -->
  227. </div>
  228. </template>
  229. <script>
  230. import ExcelJS from "exceljs";
  231. import { postapi, getapi } from "@/api/api";
  232. import { mapState } from "vuex";
  233. export default {
  234. data() {
  235. return {
  236. apiCol: {
  237. sexName: "姓名",
  238. sex: "性别",
  239. cettictetype: "证件类型",
  240. idNo: "证件号码",
  241. samplingpoints: "采样点",
  242. population: "所属人群",
  243. administrativedivision: "行政人员",
  244. testtubebarcode: "试管条码",
  245. },
  246. percentage: false,
  247. checked: "",
  248. input: "",
  249. form: {
  250. nameType: "N",
  251. cardLength: "",
  252. isAutoCreateDepartment: "N", //
  253. customerOrgId: "", //单位id
  254. isAutoCreatePatientNo: "N",
  255. cardStartNum: "0",
  256. patientName: "",
  257. organizationUnitId: "",
  258. },
  259. examinatioitems: [], //体检中心的数据
  260. value: "",
  261. nameType: "1",
  262. currentRow: null,
  263. radio: "1",
  264. dialogVisible1: true,
  265. dialogVisible2: false,
  266. dialogVisible3: false,
  267. dialogVisible4: false,
  268. dialogVisible5: false,
  269. dialogVisible6: false,
  270. startRow: 2, //数据开始行,标题行为 startRow - 1 ;
  271. importData: [], //导入原始数据
  272. tableDataCol: [], //导入原始数据 {excelCol,apiCol,label}
  273. tableData: [], //导入原始数据 分析后 表格数据
  274. formrow: {},
  275. departmentdata: [], //单位分组
  276. object: {},
  277. };
  278. },
  279. computed: {
  280. ...mapState(["importexcel"]),
  281. },
  282. methods: {
  283. colcliick(v) {
  284. console.log(v);
  285. },
  286. setCurrents() {},
  287. submitto() {
  288. if (this.form.customerOrgId == undefined) {
  289. this.$message.warning("请选择单位");
  290. } else {
  291. this.tableData.forEach((item) => {
  292. item.customerOrgId = this.form.customerOrgId;
  293. postapi(
  294. "/api/app/patientregister/createpatientregisterexcel",
  295. item
  296. ).then((res) => {
  297. if (res.code == 1) {
  298. this.object = this.form;
  299. this.importexcel = this.form;
  300. this.dialogVisible6 = true;
  301. this.dialogVisible5 = false;
  302. // this.$message.success(res.data.msg);
  303. } else {
  304. this.$confirm("导入出错, 是否继续?", "提示", {
  305. confirmButtonText: "确定",
  306. cancelButtonText: "取消",
  307. type: "warning",
  308. }).then((res) => {
  309. // let targettitle = res.Message;
  310. this.$message.warning(res.Message);
  311. });
  312. }
  313. });
  314. });
  315. // .then((rut) => {
  316. // this.tableData.forEach((item) => {
  317. // postapi(
  318. // "/api/app/patientregister/createpatientregisterexcel",
  319. // item
  320. // ).then((rut) => {
  321. // if (rut.code == 1) {
  322. // this.$message.success(rut.data.msg);
  323. // } else {
  324. // this.$message.warning(rut.Message);
  325. // }
  326. // });
  327. // });
  328. // });
  329. console.log(this.form);
  330. }
  331. console.log(this.form.customerOrgId);
  332. },
  333. //改进:
  334. //分析 不要单独按钮,合并到 下一步 按钮
  335. //进度条
  336. //登记状态 选不了
  337. //自动创建部门勾不上
  338. //数据列没有绑定
  339. async submitBatch() {
  340. let res = null,
  341. confirm = null;
  342. for (let i = 0; i < this.tableData.length; i++) {
  343. this.tableData[i].isAutoCreateDepartment =
  344. this.form.isAutoCreateDepartment;
  345. this.tableData[i].customerOrgId = this.form.customerOrgId;
  346. this.tableData[i].organizationUnitId = this.form.organizationUnitId;
  347. // this.tableData[0].name = this.tableData[0];
  348. // this.tableData[i]name=this.
  349. // if(this.tableData[i]==3){
  350. // this.tableData[i]=name
  351. // }
  352. console.log(i, this.tableData[i]);
  353. try {
  354. res = await postapi(
  355. "/api/app/patientregister/createpatientregisterexcel",
  356. this.tableData[i]
  357. ); //错误:数据没有绑定
  358. } catch (error) {
  359. return;
  360. }
  361. this.percentage = true; //进度条
  362. console.log(i, res);
  363. if (res.code != 1) {
  364. try {
  365. await this.$confirm("导入数据出错, 是否继续导入?", "提示", {
  366. confirmButtonText: "是",
  367. cancelButtonText: "否",
  368. type: "warning",
  369. showClose: false,
  370. });
  371. } catch (error) {
  372. return;
  373. }
  374. }
  375. }
  376. },
  377. onchange(id) {
  378. // this.form.customerOrgId = id;
  379. // console.log(id);
  380. // this.form.customerOrgId=this.form.customerOrgId[0]
  381. this.form.customerOrgId.forEach((item) => {
  382. // console.log(item);
  383. this.form.customerOrgId = item;
  384. });
  385. console.log(this.form.customerOrgId);
  386. },
  387. splices() {
  388. if (this.nameType == 1) {
  389. this.nameType = "同名病人提示";
  390. console.log(this.nameType);
  391. console.log(this.form.nameType);
  392. }
  393. console.log(this.nameType);
  394. },
  395. slicetdata() {
  396. console.log("2");
  397. getapi("/api/app/customer-org/by-code-all").then((res) => {
  398. this.gettypelist(res.data);
  399. this.departmentdata = res.data;
  400. console.log(res);
  401. });
  402. },
  403. gettypelist(listdata) {
  404. listdata.forEach((items) => {
  405. if (items.treeChildren.length > 0) {
  406. this.gettypelist(items.treeChildren);
  407. } else {
  408. items.treeChildren = undefined;
  409. }
  410. });
  411. },
  412. tablenext() {
  413. if (JSON.stringify(this.formrow) == "{}") {
  414. this.$message.warning("请选择数据");
  415. } else {
  416. this.form = this.formrow;
  417. this.dialogVisible5 = true;
  418. this.dialogVisible4 = false;
  419. this.slicetdata();
  420. this.getexamination();
  421. //获取调用接口的地方
  422. }
  423. },
  424. //获取调用体检中心的接口
  425. getexamination() {
  426. getapi("/api/app/organization-units/organization-unit-by-is-peis").then(
  427. (res) => {
  428. this.examinatioitems = res.data;
  429. console.log(res, "res");
  430. }
  431. );
  432. },
  433. determine() {
  434. if (JSON.stringify(this.formrow) == "{}") {
  435. this.$message.warning("请选择数据");
  436. } else {
  437. this.dialogVisible5 = true;
  438. this.dialogVisible4 = false;
  439. }
  440. },
  441. rowclick(row) {
  442. // console.log(row);
  443. this.form.patientName = row.姓名;
  444. this.form.sexName = row.性别;
  445. this.form.idNo = row.证件号码;
  446. this.formrow = row;
  447. // this.form.birthDate = row.this.formrow = row;
  448. // console.log(this.formrow);
  449. },
  450. aa() {
  451. console.log("1");
  452. },
  453. setCurrent(row) {
  454. console.log(row);
  455. // row.forEach(item=>{
  456. // console.log(item,'22222');
  457. // })
  458. // toggleRowSelection
  459. // setCurrentRow
  460. this.$refs.singleTable.setCurrentRow(row);
  461. // console.log(row, column, "event", "cell");
  462. // console.log(this.$refs.singleTable);
  463. },
  464. handleCurrentChange(val) {
  465. this.currentRow = val;
  466. },
  467. onFileChange(event) {
  468. // 获取上传的文件
  469. const file = event.target.files[0];
  470. // 调用导入Excel文件的方法
  471. this.importExcelFile(file);
  472. this.parseImportData();
  473. },
  474. importExcelFile(file) {
  475. this.filepopupdialogVisible = true;
  476. console.log("333");
  477. // 创建一个工作簿
  478. const workbook = new ExcelJS.Workbook();
  479. // 读取Excel文件
  480. const reader = new FileReader();
  481. console.log(reader);
  482. reader.onload = () => {
  483. const buffer = reader.result;
  484. const typedArray = new Uint8Array(buffer);
  485. const blob = new Blob([typedArray], {
  486. type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
  487. });
  488. // 从Blob中读取Excel文件
  489. workbook.xlsx.load(blob).then((workbook) => {
  490. // 获取第一个工作表
  491. const worksheet = workbook.getWorksheet(1);
  492. // 处理Excel文件内容
  493. worksheet.eachRow((row, rowNumber) => {
  494. console.log(row.values);
  495. this.importData.push(row.values);
  496. // console.log(`第${row.rowNumber}行的数据:${row.rowData}`);
  497. });
  498. });
  499. };
  500. reader.readAsArrayBuffer(file);
  501. },
  502. //导入后数据分析
  503. parseImportData(startRow) {
  504. if (!this.importData || this.importData.length == 0) return;
  505. let cols = [];
  506. let record = {};
  507. this.importData.forEach((item, index) => {
  508. console.log(index, item);
  509. if (index == startRow - 2) {
  510. item.forEach((e, i) => {
  511. console.log("e", i, e);
  512. if (i > 0) {
  513. if (e) {
  514. this.tableDataCol.push({ excelCol: e, apiCol: "", label: e });
  515. cols.push(e);
  516. } else {
  517. this.tableDataCol.push({
  518. excelCol: `${Number(i) + 1}`,
  519. apiCol: "",
  520. lebel: `${Number(i) + 1}`,
  521. });
  522. cols.push(`${Number(i) + 1}`);
  523. }
  524. }
  525. });
  526. } else if (index > startRow - 2) {
  527. for (let i = 0; i < item.length; i++) {
  528. if (i > 0) {
  529. console.log("cols[i]", i, cols[i - 1]);
  530. if (item[i]) {
  531. record[cols[i - 1]] = item[i];
  532. } else {
  533. record[cols[i - 1]] = null;
  534. }
  535. }
  536. }
  537. this.tableData.push({ ...record });
  538. }
  539. });
  540. console.log("tableDataCol", this.tableDataCol);
  541. console.log("tableData", this.tableData);
  542. },
  543. nextclick() {
  544. if (this.tableData.length > 1) {
  545. console.log("1");
  546. this.dialogVisible4 = true;
  547. this.dialogVisible3 = false;
  548. //支付方式
  549. getapi("/api/app/pay-mode").then((res) => {
  550. this.paymodedata = res.data;
  551. });
  552. //婚姻状况
  553. getapi("/api/app/marital-statuses").then((res) => {
  554. this.maritalstatusesdata = res.data;
  555. console.log(res);
  556. });
  557. //团检登记
  558. getapi("/api/app/customer-org-register/in-filter").then((res) => {
  559. console.log(res);
  560. });
  561. } else {
  562. this.$message.warning("请选择导入的文件并解析");
  563. }
  564. console.log(this.tableData);
  565. },
  566. nextTick() {
  567. if (this.radio == 1) {
  568. this.dialogVisible1 = false;
  569. this.dialogVisible2 = true;
  570. }
  571. console.log(this.radio);
  572. },
  573. back4() {
  574. this.dialogVisible4 = false;
  575. this.dialogVisible3 = true;
  576. },
  577. back3() {
  578. this.dialogVisible3 = false;
  579. this.dialogVisible2 = true;
  580. },
  581. // 上一步
  582. back2() {
  583. this.dialogVisible2 = false;
  584. this.dialogVisible1 = true;
  585. },
  586. //下一步
  587. nextstep() {
  588. this.dialogVisible3 = true;
  589. this.dialogVisible2 = false;
  590. },
  591. loading() {},
  592. },
  593. };
  594. </script>
  595. <style scoped>
  596. .subheading {
  597. margin-left: 10%;
  598. }
  599. .selectfile {
  600. display: flex;
  601. }
  602. .boxtitle {
  603. margin-left: 25%;
  604. margin-top: 20px;
  605. }
  606. .mainbody {
  607. width: 100%;
  608. }
  609. .heading {
  610. text-align: center;
  611. font-size: 18px;
  612. }
  613. .selectby {
  614. display: flex;
  615. justify-content: center;
  616. }
  617. </style>