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.

466 lines
18 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
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
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
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
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 style="display: flex;">
  3. <div v-if="useCusOrg" style="width: 258px;height:520px;border: 1px solid #EEE;">
  4. <div style="margin:2px 2px 2px 2px;">
  5. <el-input placeholder="输入关键字进行过滤" v-model="filterText" size="small" />
  6. </div>
  7. <div>
  8. <el-tree style="overflow: scroll;width: 200px;height:480px;" :data="patientRegister.customerOrgTreeAll"
  9. :props="treeprops" @node-click="handleNode" :filter-node-method="filterNode"
  10. ref="customerOrgTree">
  11. <span class="custom-tree-node" slot-scope="{ node, data }">
  12. <div>
  13. <span class="treeicons">
  14. <!-- <i
  15. class="el-icon-document-remove"
  16. v-if="data.parentId == null"
  17. ></i> -->
  18. <img style="width:20px;height:20px;vertical-align: sub;" src="@/assets/images/order.png"
  19. v-if="!data.parentId" />
  20. </span>
  21. <span :class="!data.parentId ? 'maxtitle' : 'mintitle'">{{ node.label }}
  22. </span>
  23. </div>
  24. </span>
  25. </el-tree>
  26. </div>
  27. </div>
  28. <div :style="`display: block;width:${useCusOrg ? 635 : 855}px; margin-left: 5px;`">
  29. <el-table :data="dataCusOrgOCX" border height="470" highlight-current-row @row-dblclick="rowDblclick"
  30. size="small">
  31. <el-table-column prop="customerOrgName" label="体检单位" min-width="150" />
  32. <el-table-column prop="customerOrgId" label="次数" min-width="52" align="center">
  33. <template slot-scope="scope">
  34. <el-select v-model="scope.row.customerOrgRegister" placeholder="次数" style="width: 44px;" size="small"
  35. :disabled="!useCusOrg || scope.row.customerOrgId == dict.personOrgId"
  36. @change="changeMedicalTimes(scope.$index)" value-key="id">
  37. <el-option v-for="item in scope.row.customerOrgRegisterList" :key="item.id" :label="item.medicalTimes"
  38. :value="item" />
  39. </el-select>
  40. </template>
  41. </el-table-column>
  42. <!--
  43. <el-table-column prop="dateType" label="日期方式" width="85" align="center">
  44. <template slot-scope="scope">
  45. <el-select v-model="scope.row.dateType" placeholder="请选择" filterable clearable size="small">
  46. <el-option label="登记日期" value="creationTime" />
  47. <el-option label="体检日期" value="medicalStartDate" />
  48. <el-option label="总检日期" value="summaryDate" />
  49. </el-select>
  50. </template>
  51. </el-table-column>
  52. -->
  53. <el-table-column prop="startDate" label="起始日期" min-width="96" align="center">
  54. <template slot-scope="scope">
  55. <el-date-picker v-model="scope.row.startDate" type="date" placeholder="截止日期"
  56. :style="`width: ${useCusOrg ? 90 : 120}px;`" size="small" />
  57. </template>
  58. </el-table-column>
  59. <el-table-column prop="endDate" label="截止日期" min-width="96" align="center">
  60. <template slot-scope="scope">
  61. <el-date-picker v-model="scope.row.endDate" type="date" placeholder="截止日期"
  62. :style="`width: ${useCusOrg ? 90 : 120}px;`" size="small" />
  63. </template>
  64. </el-table-column>
  65. <el-table-column prop="customerOrgGroupIds" label="分组" min-width="200">
  66. <template slot-scope="scope">
  67. <el-select v-model="scope.row.customerOrgGroupIds" multiple collapse-tags filterable clearable
  68. style="width:192px;" placeholder="请选择分组" size="small"
  69. @focus="getCustGroup(scope.$index, scope.row.customerOrgRegister.id)"
  70. :disabled="!useCusOrg || scope.row.customerOrgId == dict.personOrgId">
  71. <el-option v-for="item in scope.row.customerOrgGroupList" :key="item.value" :label="item.displayName"
  72. :value="item.id" />
  73. </el-select>
  74. </template>
  75. </el-table-column>
  76. <el-table-column min-width="24" align="center">
  77. <template slot-scope="scope">
  78. <i class="el-icon-delete" @click="rowDblclick(scope.row)"
  79. style="font-size: 20px;color: red;cursor:pointer;"></i>
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. <div style="display: flex;margin-top: 8px;margin-left: 15px;">
  84. <div style="display: block;">
  85. <div>
  86. <span>日期方式</span>
  87. <el-radio-group v-model="dateType" @change="changeDateType">
  88. <el-radio label="creationTime">登记日期</el-radio>
  89. <el-radio label="medicalStartDate">体检日期</el-radio>
  90. <el-radio label="summaryDate">总检日期 </el-radio>
  91. </el-radio-group>
  92. </div>
  93. <div style="margin-top: 5px;">
  94. <span>单位作为查询条件</span>
  95. <el-checkbox v-model="useCusOrg" @change="changeUseOrg" :disabled="isUnit" />
  96. </div>
  97. </div>
  98. <div style="margin-left: 150px;margin-top: 5px;">
  99. <el-button type="primary" @click="btnOk" class="commonbutton">确定</el-button>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </template>
  105. <script>
  106. import moment from "moment";
  107. import { mapState } from "vuex";
  108. import { getapi, postapi, putapi, deletapi } from "@/api/api";
  109. import { arrayExistObj, deepCopy, reMadeOrgTree } from "../../utlis/proFunc";
  110. import { getTreePids, getTreeAllChildIdsById } from "../../utlis/tree";
  111. export default {
  112. components: {},
  113. props: ["useCustomerOrg", "initDateType", "isUnit"],
  114. data() {
  115. return {
  116. filterText: '',
  117. preNodeId: '', //上一次点击树节点
  118. curNodeId: '', //本次点击树节点
  119. dateType: 'medicalStartDate',
  120. useCusOrg: false, //是否使用单位
  121. isUnitOption: false,//是否禁用单位勾选
  122. //体检单位,体检次数,日期类型,起止日期,分组
  123. dataCusOrgOCX: [{
  124. id: '', //随机的ID,用于删除
  125. customerOrgId: '', //
  126. customerOrgName: '', //企业名称,显示用
  127. customerOrgRegister: {}, //已选的体检次数
  128. customerOrgRegisterList: [], //当前单位的体检次数信息
  129. dateType: 'medicalStartDate', // 登记日期:creationTime;体检日期:medicalStartDate;总检日期:summaryDate
  130. startDate: '',
  131. endDate: '',
  132. customerOrgGroupIds: [], //已选分组
  133. customerOrgGroupList: [], //可选的分组
  134. }],
  135. treeprops: {
  136. label: "displayName", // label/displayName
  137. value: "id",
  138. id: "id",
  139. children: "treeChildren",
  140. }, //树形组件的数据结构
  141. };
  142. },
  143. //<el-tree :data="$store.state.customerOrg.customerOrgTree" :props="$store.state.customerOrg.treeprops" @node-click="treeclick"></el-tree>
  144. computed: {
  145. ...mapState(["dict", "customerOrg", "patientRegister", "report", "diagnosis", "project"]),
  146. },
  147. //创建组件后
  148. created() {
  149. this.dataCusOrgOCX = [];
  150. if (this.useCustomerOrg) {
  151. this.useCusOrg = true
  152. }
  153. if (this.initDateType) {
  154. this.dateType = this.initDateType
  155. }
  156. if (this.isUnit) {
  157. this.isUnitOption = true
  158. }
  159. this.changeUseOrg(this.useCusOrg)
  160. },
  161. //挂载组件完成
  162. mounted() {
  163. //获取体检单位列表树信息
  164. this.getCustomerOrgTree();
  165. },
  166. methods: {
  167. //树过滤
  168. filterNode(value, data) {
  169. //console.log(value,data)
  170. if (!value) return true;
  171. return data['displayName'].indexOf(value) !== -1 || data['simpleCode'].indexOf(value.toUpperCase()) !== -1;
  172. },
  173. //获取体检单位列表树信息
  174. getCustomerOrgTree() {
  175. getapi("/api/app/customerorg/getbycodeall").then((res) => {
  176. if (res.code > -1) {
  177. this.patientRegister.customerOrgTreeAll = reMadeOrgTree(deepCopy(res.data));
  178. //tcdate(this.patientRegister.customerOrgTreeAll)
  179. }
  180. });
  181. },
  182. //获取体检单位父级ID api/app/customer-org/parent/[CustomerOrgld
  183. getCustomerOrgParentId(customerOrgld) {
  184. if (customerOrgld == this.dict.personOrgId) {
  185. this.patientRegister.query.CustomerOrgParentId = this.dict.personOrgId;
  186. return;
  187. }
  188. getapi(`/api/app/customer-org/parent/${customerOrgld}`).then((res) => {
  189. console.log("res.data", res.data);
  190. if (res.code == 1) {
  191. this.patientRegister.query.CustomerOrgParentId = res.data;
  192. }
  193. });
  194. },
  195. //点击树节点
  196. treeclick(data) {
  197. this.patientRegister.query.customerOrgId = data.id;
  198. this.getCustomerOrgParentId(data.id);
  199. this.patientRegister.query.times++; //用于触发查询条件
  200. },
  201. //树控件--伪双击事件
  202. handleNode(data, node, prop) {
  203. // console.log(data, node, prop);
  204. if (!this.preNodeId) {
  205. this.preNodeId = data.id;
  206. } else {
  207. this.curNodeId = data.id;
  208. }
  209. //双击事件
  210. if (this.preNodeId == this.curNodeId) { //第一次点击的节点和第二次点击的节点id相同
  211. this.preNodeId = null;
  212. this.curNodeId = null;
  213. this.treeDbClick(data);
  214. return;
  215. }
  216. this.nodeTimer = setTimeout(() => { //300ms内没有第二次点击就把第一次点击的清空
  217. this.preNodeId = null;
  218. }, 300)
  219. },
  220. //双击树节点 后续处理
  221. async treeDbClick(node) {
  222. //console.log('this.patientRegister.customerOrgTreeAll',this.patientRegister.customerOrgTreeAll);
  223. if (!this.useCusOrg) {
  224. this.$message.info({ showClose: true, message: "请先勾选单位作为查询条件" });
  225. return;
  226. }
  227. //待添加的记录
  228. let ldate = new Date();
  229. let record = {
  230. id: parseInt(Math.random() * 100000000),
  231. customerOrgId: node.id,
  232. customerOrgName: node.displayName,
  233. customerOrgRegister: {}, //已选的体检次数
  234. customerOrgRegisterList: [], //当前单位的体检次数信息
  235. dateType: 'creationTime', // 登记日期:creationTime;体检日期:medicalStartDate;总检日期:summaryDate
  236. startDate: ldate,
  237. endDate: ldate,
  238. customerOrgGroupIds: [], //已选的体检分组
  239. customerOrgGroupList: [], //可选的分组
  240. }
  241. if (node.id != this.dict.personOrgId) {
  242. try {
  243. let res = await getapi(`/api/app/customer-org/parent/${node.id}`);
  244. let res1 = await getapi(`/api/app/customerorgregister/getlistincustomerorgid?CustomerOrgId=${res.data}`);
  245. record.customerOrgRegisterList = res1.data;
  246. if (res1.data && res1.data.length > 0) {
  247. record.customerOrgRegister = res1.data[res1.data.length - 1];
  248. record.startDate = res1.data[res1.data.length - 1].beginTime;
  249. record.endDate = res1.data[res1.data.length - 1].isComplete == 'N' ? ldate : res1.data[res1.data.length - 1].endTime;
  250. }
  251. } catch (error) {
  252. console.log(`get: /api/app/customer-org/parent/${node.id} /api/app/customerorgregister/getlistincustomerorgid?CustomerOrgId=${node.id}`, error)
  253. }
  254. }
  255. let checkMsg = this.checkQuery(record, this.dataCusOrgOCX, 0, -1);
  256. if (checkMsg) {
  257. this.$message.warning({ showClose: true, message: checkMsg });
  258. return;
  259. }
  260. this.dataCusOrgOCX.push(record);
  261. },
  262. //查询条件合法性检测
  263. checkQuery(record, dataCusOrgOCX, startRow, currRow) {
  264. //currRow 为 - 1 时,record 表示 待添加记录 ,否则为 dataCusOrgOCX 列表数据 合法性检测
  265. if (!record.customerOrgId) return '';
  266. if (!dataCusOrgOCX || dataCusOrgOCX.length < 1) return '';
  267. let checkMsg = '';
  268. let parentIds = getTreePids(this.patientRegister.customerOrgTreeAll, 'treeChildren', 'parentId', 'id', record.customerOrgId);
  269. let childIds = getTreeAllChildIdsById(this.patientRegister.customerOrgTreeAll, 'treeChildren', 'id', record.customerOrgId);
  270. for (let i = startRow; i < dataCusOrgOCX.length; i++) {
  271. if (dataCusOrgOCX[i].customerOrgId == record.customerOrgId && dataCusOrgOCX[i].customerOrgRegister.id == record.customerOrgRegister.id) {
  272. if (currRow < 0) {
  273. checkMsg = "已经添加了该单位,不可再添加";
  274. } else {
  275. checkMsg = `${Number(currRow) + 1} 行与第 ${Number(i) + 1} 行,单位与体检次数相同,数据校验失败!`;
  276. }
  277. break;
  278. }
  279. if (parentIds.indexOf(dataCusOrgOCX[i].customerOrgId) > - 1 && dataCusOrgOCX[i].customerOrgRegister.id == record.customerOrgRegister.id) {
  280. if (currRow < 0) {
  281. checkMsg = "已经添加了该单位的上级单位,不可再添加该单位";
  282. } else {
  283. checkMsg = `${Number(currRow) + 1} 行与第 ${Number(i) + 1} 行,体检次数相同单位存在上下级关系,数据校验失败!`;
  284. }
  285. break;
  286. }
  287. if (childIds.indexOf(dataCusOrgOCX[i].customerOrgId) > - 1 && dataCusOrgOCX[i].customerOrgRegister.id == record.customerOrgRegister.id) {
  288. if (currRow < 0) {
  289. checkMsg = "已经添加了该单位的下级单位,不可再添加该单位";
  290. } else {
  291. checkMsg = `${Number(currRow) + 1} 行与第 ${Number(i) + 1} 行,体检次数相同单位存在上下级关系,数据校验失败!`;
  292. }
  293. break;
  294. }
  295. }
  296. return checkMsg;
  297. },
  298. //修改体检次数,更改起止日期
  299. changeMedicalTimes(index) {
  300. let v = this.dataCusOrgOCX[index].customerOrgRegister;
  301. this.dataCusOrgOCX[index].startDate = v.beginTime;
  302. this.dataCusOrgOCX[index].endDate = v.isComplete == 'N' ? new Date() : v.endTime;
  303. //清除选的分组
  304. this.dataCusOrgOCX[index].customerOrgGroupIds = [];
  305. },
  306. //获取分组
  307. getCustGroup(index, groupId) {
  308. ///api/app/customerorggroup/getlistinfilter?CustomerOrgRegisterId=3fa85f64-5717-4562-b3fc-2c963f66afa6
  309. getapi(`/api/app/customerorggroup/getlistinfilter?CustomerOrgRegisterId=${groupId}`).then(res => {
  310. if (res.code != - 1) {
  311. this.dataCusOrgOCX[index].customerOrgGroupList = res.data;
  312. }
  313. })
  314. },
  315. //选择日期方式
  316. changeDateType(v) {
  317. this.dataCusOrgOCX.forEach(e => {
  318. e.dateType = v;
  319. return e;
  320. })
  321. },
  322. changeUseOrg(v) {
  323. let ldate = new Date();
  324. this.dataCusOrgOCX = [];
  325. if (!v) {
  326. this.dataCusOrgOCX.push({
  327. id: parseInt(Math.random() * 100000000),
  328. customerOrgId: '',
  329. customerOrgName: '',
  330. customerOrgRegister: {}, //已选的体检次数
  331. customerOrgRegisterList: [], //当前单位的体检次数信息
  332. dateType: 'medicalStartDate', // 登记日期:creationTime;体检日期:medicalStartDate;总检日期:summaryDate
  333. startDate: ldate,
  334. endDate: ldate,
  335. customerOrgGroupIds: [], //已选的体检分组
  336. customerOrgGroupList: [], //可选的分组
  337. })
  338. }
  339. },
  340. //双击删除该行查询条件
  341. rowDblclick(row) {
  342. if (!this.useCusOrg) return
  343. let lfind = arrayExistObj(this.dataCusOrgOCX, 'id', row.id);
  344. if (lfind > -1) this.dataCusOrgOCX.splice(lfind, 1);
  345. },
  346. //选择单位
  347. changeCustomerOrgId(v) {
  348. console.log(v)
  349. if (!v) {
  350. this.patientRegister.query.customerOrgRegister = null;
  351. return;
  352. }
  353. let customerOrgId = v[0];
  354. if (customerOrgId == this.dict.personOrgId) {
  355. this.patientRegister.query.customerOrgRegister = null;
  356. return;
  357. }
  358. getapi(
  359. `/api/app/customerorgregister/getlistincustomerorgid?CustomerOrgId=${customerOrgId}`
  360. ).then((res) => {
  361. //console.log('res.data',res.data)
  362. if (res.code != -1) {
  363. this.customerOrg.customerOrgRegisterList = res.data;
  364. if (res.data.length > 0) {
  365. this.patientRegister.query.customerOrgRegister = res.data[res.data.length - 1];
  366. this.patientRegister.query.dateRange = [
  367. res.data[res.data.length - 1].beginTime,
  368. res.data[res.data.length - 1].isComplete == 'N' ? new Date() : res.data[res.data.length - 1].endTime
  369. ]
  370. }
  371. }
  372. });
  373. },
  374. btnOk() {
  375. let checkMsg = '', cusOrgOCX = '';
  376. for (let i = 0; i < this.dataCusOrgOCX.length; i++) {
  377. this.dataCusOrgOCX[i].dateType = this.dateType
  378. checkMsg = this.checkQuery(this.dataCusOrgOCX[i], this.dataCusOrgOCX, i + 1, i);
  379. if (checkMsg) break;
  380. }
  381. if (checkMsg) {
  382. this.$message.warning({ showClose: true, message: checkMsg });
  383. return;
  384. }
  385. if (this.dataCusOrgOCX && this.dataCusOrgOCX.length > 0) {
  386. cusOrgOCX = this.dataCusOrgOCX[0].customerOrgName || '';
  387. // debugger // this.dataCusOrgOCX[0].dateType
  388. switch (this.dateType) {
  389. case 'medicalStartDate':
  390. cusOrgOCX += "(体检"
  391. break;
  392. case 'summaryDate':
  393. cusOrgOCX += "(总检"
  394. break;
  395. default:
  396. cusOrgOCX += "(登记"
  397. break;
  398. }
  399. cusOrgOCX += moment(this.dataCusOrgOCX[0].startDate).format('yyyy-MM-DD') + '~' + moment(this.dataCusOrgOCX[0].endDate).format('yyyy-MM-DD') + ')';
  400. }
  401. this.report.dataCusOrgOCX = this.dataCusOrgOCX;
  402. this.diagnosis.dataCusOrgOCX = this.dataCusOrgOCX;
  403. this.project.dataCusOrgOCX = this.dataCusOrgOCX;
  404. this.patientRegister.query.cusOrgOCX = cusOrgOCX
  405. this.report.dialogCusOrgOCX = false;
  406. this.diagnosis.dialogCusOrgOCX = false;
  407. this.project.dialogCusOrgOCX = false;
  408. },
  409. },
  410. watch: {
  411. "filterText"(newVal, oldVal) {
  412. this.$refs['customerOrgTree'].filter(newVal);
  413. }
  414. },
  415. };
  416. </script>
  417. <style lang="scss" scoped>
  418. @import "../../assets/css/global_dialog.css";
  419. @import "../../assets/css/global_table.css";
  420. @import "../../assets/css/global_input.css";
  421. @import "../../assets/css/global.css";
  422. @import "../../assets/css/global_tree.css";
  423. :deep .el-tree-node>.el-tree-node__children {
  424. overflow: visible;
  425. }
  426. </style>