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.

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