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.

638 lines
24 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
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
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="margin-left: 10px">
  3. <div>
  4. <span>项目类别</span>
  5. <el-cascader :options="dict.itemTypeTree" v-model="itemTypeIds"
  6. :props="{ checkStrictly: true, expandTrigger: 'hover', ...customerOrg.treeprops, }" :show-all-levels="false"
  7. clearable filterable @change="getAsbItemByItemType">
  8. </el-cascader>
  9. </div>
  10. <div class="mainareaBox">
  11. <el-table :header-cell-style="{ background: '#eef1f6' }" :data="dict.asbItem" height="200"
  12. @selection-change="handleSelectionChange" size="small">
  13. <el-table-column type="selection"></el-table-column>
  14. <el-table-column label="未选组合项目" prop="displayName"></el-table-column>
  15. </el-table>
  16. </div>
  17. <div class="mainbutton">
  18. <div style="margin-left: 10px">
  19. <el-button type="primary" @click="addAbs">添加 <i class="el-icon-bottom"></i>
  20. </el-button>
  21. </div>
  22. <div style="margin-left: 10px">
  23. <el-button type="primary" @click="delAbs">移除 <i class="el-icon-top"></i>
  24. </el-button>
  25. </div>
  26. <div style="margin-left: 10px">
  27. <el-button type="success" @click="onSubmit('保存')">保存 <i class="el-icon-check"></i>
  28. </el-button>
  29. </div>
  30. </div>
  31. <div class="mainareaBox">
  32. <el-table :data="patientRegister.patientRegisterAbs" height="200" :summary-method="getSummaries" show-summary
  33. @selection-change="selecteditems" size="small">
  34. <!-- temporaryselection personnelUnit.nogroupselected-->
  35. <el-table-column type="selection"></el-table-column>
  36. <el-table-column label="已选组合项目" width="110" prop="asbitemName" />
  37. <el-table-column label="标准价格" prop="standardPrice" />
  38. <el-table-column label="折扣" prop="discount">
  39. <template slot-scope="scope">
  40. <el-input v-model="scope.row.discount" size="small" />
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="实收价格" prop="chargePrice">
  44. <template slot-scope="scope">
  45. <el-input v-model="patientRegister.patientRegisterAbs[scope.$index].chargePrice" size="small" />
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="数量" prop="amount">
  49. <template slot-scope="scope">
  50. <el-input v-model="patientRegister.patientRegisterAbs[scope.$index].amount" size="small" />
  51. </template>
  52. </el-table-column>
  53. <el-table-column label="支付方式" prop="payTypeFlag" width="100">
  54. <template slot-scope="scope">
  55. <el-select v-model="patientRegister.patientRegisterAbs[scope.$index].payTypeFlag" size="small">
  56. <el-option v-for="item in dict.payType" :key="item.id" :label="item.displayName" :value="item.id"
  57. width="100" />
  58. </el-select>
  59. </template>
  60. </el-table-column>
  61. </el-table>
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. import { mapState, mapActions } from "vuex";
  67. import { getapi, postapi, putapi, deletapi } from "@/api/api";
  68. import { arrayFilter, arrayReduce, arrayExistObj } from "../../utlis/proFunc";
  69. export default {
  70. props: ["patientRegisterForm"],
  71. data() {
  72. return {
  73. itemType: [], //项目类别
  74. itemTypeIds: '', //被选中的项目类别ID
  75. asbItemChoosed: [], //勾选的 未选组合项目
  76. //patientRegisterAbs:[], //体检人员所选组合项目 放vuex
  77. patientRegisterAbsChoosed: [], //勾选的 体检人员所选组合项目
  78. //patientRegisterAbsDel: [], //体检人员 待删除的组合项目
  79. patientRegisterAbsRd: {
  80. id: null, //更新不需传
  81. asbitemId: null, // string($uuid) 组合项目
  82. asbitemName: '', //组合项目名称,更新不需传
  83. patientRegisterId: null, //string($uuid) 登记流水号
  84. standardPrice: 0, //number($double) 标准价格
  85. chargePrice: 0, // number($double) 实收价格
  86. payTypeFlag: "0", // string 支付方式,比如是自费、免费、单位支付 0自费、2免费、1单位支付
  87. isCharge: "N", // string 是否已收费
  88. //lisRequestId: null, // string($uuid)LIS申请ID
  89. amount: 1, // integer($int32) 数量
  90. groupPackageId: null, // string($uuid) 分组或者套餐ID
  91. }, //单个添加的组合项目
  92. };
  93. },
  94. computed: {
  95. ...mapState(["dict", "customerOrg", "patientRegister", "personnelUnit"]),
  96. },
  97. mounted() { },
  98. methods: {
  99. ...mapActions(['getCustomerOrgGroup', 'getMedicalPackageAsb', 'getPatientRegisterAbs']),
  100. //保存按钮
  101. // [
  102. // {
  103. // "registerAsbitemId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  104. // "input": {
  105. // "chargePrice": 0,
  106. // "payTypeFlag": "string",
  107. // "isCharge": "string",
  108. // "amount": 0,
  109. // "groupPackageId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
  110. // }
  111. // }
  112. // ]
  113. //批量更新组合项目
  114. async batchEditAsb(body, msg) {
  115. console.log(`/api/app/registerasbitem/updatemany`, body)
  116. postapi(`/api/app/registerasbitem/updatemany`, body)
  117. .then((res) => {
  118. console.log("onSubmit", res);
  119. if (res.code == 1) {
  120. if (msg) {
  121. //未选项目中移除,已选项中添加
  122. this.getPatientRegisterAbs(this.patientRegisterForm.id)
  123. this.$message.success(`${msg}操作成功`);
  124. }
  125. }
  126. })
  127. .catch((err) => {
  128. this.$message({ type: "error", message: `${msg}操作失败,原因:${err}` });
  129. });
  130. },
  131. //更新所选组合项目
  132. async onSubmit(msg) {
  133. let body = [], insBody = []
  134. if (!this.patientRegisterForm.id) {
  135. alert("请先保存人员体检基本信息!")
  136. return
  137. }
  138. if (this.patientRegister.patientRegisterAbs.length < 1) {
  139. alert("暂无可操作的数据")
  140. return
  141. }
  142. for (let i = 0; i < this.patientRegister.patientRegisterAbs.length; i++) {
  143. if (this.patientRegister.patientRegisterAbs[i].id) {
  144. body.push({
  145. registerAsbitemId: this.patientRegister.patientRegisterAbs[i].id,
  146. input: {
  147. chargePrice: this.patientRegister.patientRegisterAbs[i].chargePrice,
  148. payTypeFlag: this.patientRegister.patientRegisterAbs[i].payTypeFlag,
  149. isCharge: this.patientRegister.patientRegisterAbs[i].isCharge,
  150. amount: this.patientRegister.patientRegisterAbs[i].amount,
  151. groupPackageId: this.patientRegister.patientRegisterAbs[i].groupPackageId
  152. }
  153. })
  154. } else {
  155. insBody.push({
  156. asbitemId: this.patientRegister.patientRegisterAbs[i].asbitemId,
  157. patientRegisterId: this.patientRegisterForm.id,
  158. standardPrice: this.patientRegister.patientRegisterAbs[i].standardPrice,
  159. chargePrice: this.patientRegister.patientRegisterAbs[i].chargePrice,
  160. payTypeFlag:this.patientRegister.patientRegisterAbs[i].payTypeFlag,
  161. isCharge: this.patientRegister.patientRegisterAbs[i].isCharge,
  162. amount: this.patientRegister.patientRegisterAbs[i].amount,
  163. groupPackageId: this.patientRegister.patientRegisterAbs[i].groupPackageId
  164. })
  165. }
  166. }
  167. //if (body.length > 0 ) await this.batchEditAsb(body, msg);
  168. if (body.length > 0 && insBody.length > 0){
  169. await this.batchEditAsb(body, '');
  170. await this.batchAddAsb(insBody,msg);
  171. }else if (body.length > 0 && insBody.length < 1){
  172. await this.batchEditAsb(body, msg);
  173. }else if (body.length < 1 && insBody.length > 0){
  174. await this.batchAddAsb(insBody,msg);
  175. }
  176. },
  177. //未选组合项目 勾选情况
  178. handleSelectionChange(val) {
  179. // this.selecteddata = val;
  180. this.asbItemChoosed = val;
  181. //console.log(this.asbItemChoosed);
  182. },
  183. //批量添加组合项目
  184. batchAddAsb(body, msg) {
  185. console.log(`/api/app/registerasbitem/createmany?CustomerOrgId=${this.patientRegisterForm.customerOrgId}`, body)
  186. postapi(`/api/app/registerasbitem/createmany?CustomerOrgId=${this.patientRegisterForm.customerOrgId}`, body)
  187. .then((res) => {
  188. console.log("batchAddAsb", res);
  189. if (res.code == 1) {
  190. //未选项目中移除,已选项中添加
  191. this.getPatientRegisterAbs(this.patientRegisterForm.id)
  192. if (msg) this.$message.success(`${msg}操作成功`);
  193. }
  194. })
  195. .catch((err) => {
  196. this.$message({ type: "error", message: `${msg}操作失败,原因:${err}` });
  197. });
  198. },
  199. // 添加组合项目
  200. ///api/app/register-asbitem/many/3fa85f64-5717-4562-b3fc-2c963f66afa6'
  201. addAbs() {
  202. let body = []
  203. let checked = true
  204. let payTypeFlag = '0' //默认个人支付
  205. let lfind = -1
  206. if (this.asbItemChoosed.length < 1) {
  207. alert("请选择要添加的组合项目")
  208. return
  209. }
  210. //性别、年龄判断
  211. // "displayName": "身高体重",
  212. // "shortName": "哈f哈",
  213. // "forSexId": "F",
  214. // "itemTypeId": "3a0b16de-75b9-c910-c61b-844709a88940",
  215. // "price": 0,
  216. //console.log('this.asbItemChoosed.length',this.asbItemChoosed.length)
  217. for (let i = 0; i < this.asbItemChoosed.length; i++) {
  218. if (this.patientRegisterForm.sexId == 'U') break //未选性别时,无需判断组合项目性别限制
  219. if (this.asbItemChoosed[i].forSexId == 'A') continue
  220. if (this.asbItemChoosed[i].forSexId != this.patientRegisterForm.sexId) {
  221. alert(`所选项目:${this.asbItemChoosed[i].displayName},不适合当前人员性别`)
  222. checked = false
  223. break
  224. }
  225. }
  226. //console.log(222,checked)
  227. if (!checked) return
  228. if (this.patientRegisterForm.customerOrgId != this.dict.personOrgId) payTypeFlag = '1'
  229. for (let i = 0; i < this.asbItemChoosed.length; i++) {
  230. let pojo = {
  231. asbitemId: this.asbItemChoosed[i].id,
  232. patientRegisterId: this.patientRegisterForm.id,
  233. standardPrice: this.asbItemChoosed[i].price,
  234. chargePrice: this.asbItemChoosed[i].price,
  235. payTypeFlag,
  236. isCharge: "N",
  237. amount: 1
  238. }
  239. body.push(pojo)
  240. this.patientRegister.patientRegisterAbs.push({ ...pojo, asbitemName: this.asbItemChoosed[i].displayName })
  241. lfind = arrayExistObj(this.dict.asbItem, 'id', this.asbItemChoosed[i].id)
  242. if (lfind > -1) this.dict.asbItem.splice(lfind, 1)
  243. }
  244. if (this.patientRegisterForm.id) this.batchAddAsb(body, '添加组合项目');
  245. },
  246. //人员已选组合项目 勾选情况
  247. selecteditems(val) {
  248. this.patientRegisterAbsChoosed = val
  249. },
  250. //批量删除组合项目
  251. batchDelAsb(body, msg) {
  252. console.log(`/api/app/registerasbitem/deletemany`, body)
  253. postapi(`/api/app/registerasbitem/deletemany`, body)
  254. .then((res) => {
  255. console.log("delAbs", res);
  256. if (res.code != -1) {
  257. //项目类别过滤 组合项目,未过滤已选择的组合项目
  258. this.getAsbItemByItemTypeAll()
  259. if (msg) {
  260. //未选项目中移除,已选项中添加
  261. this.getPatientRegisterAbs(this.patientRegisterForm.id)
  262. this.$message.success(`${msg}操作成功`);
  263. }
  264. }
  265. })
  266. .catch((err) => {
  267. this.$message({ type: "error", message: `${msg}操作失败,原因:${err}` });
  268. });
  269. },
  270. //删除 人员已选中的组合项目
  271. ///api/app/register-asbitem/many?RegisterAsbitemIds=3fa85f64-5717-4562-b3fc-2c963f66afa6
  272. delAbs() {
  273. let body = {}
  274. let registerAsbitemIds = []
  275. let chargeComplete = ''
  276. let lfind = -1
  277. if (this.patientRegisterAbsChoosed.length < 1) {
  278. alert("请选择要移除的组合项目")
  279. return
  280. }
  281. for (let i = 0; i < this.patientRegisterAbsChoosed.length; i++) {
  282. //未在数据库中,直接删除
  283. if (!this.patientRegisterAbsChoosed[i].id) {
  284. lfind = arrayExistObj(this.patientRegister.patientRegisterAbs, 'asbitemId', this.patientRegisterAbsChoosed[i].asbitemId)
  285. if (lfind > -1) this.patientRegister.patientRegisterAbs.splice(lfind, 1)
  286. this.patientRegisterAbsChoosed.splice(i, 1)
  287. i--
  288. continue
  289. }
  290. if (this.patientRegisterAbsChoosed[i].isCharge == 'Y' || this.patientRegisterAbsChoosed[i].checkCompleteFlag != '0') {
  291. chargeComplete += this.patientRegisterAbsChoosed[i].asbitemName + ','
  292. this.patientRegisterAbsChoosed.splice(i, 1)
  293. i--
  294. }
  295. }
  296. //刷新
  297. this.getAsbItemByItemType()
  298. if (chargeComplete) {
  299. this.$message({ type: "info", message: `所选项目:${chargeComplete}已收费或已检,不可删除!` });
  300. if (this.patientRegisterAbsChoosed.length < 1) return
  301. }
  302. for (let i = 0; i < this.patientRegisterAbsChoosed.length; i++) {
  303. registerAsbitemIds.push(this.patientRegisterAbsChoosed[i].id)
  304. }
  305. body = { registerAsbitemIds }
  306. if (registerAsbitemIds.length > 0 && this.patientRegisterForm.id) this.batchDelAsb(body, '删除组合项目');
  307. },
  308. //项目类别过滤 组合项目,未过滤已选择的组合项目
  309. getAsbItemByItemTypeAll() {
  310. console.log('getAsbItemByItemType', typeof this.itemTypeIds, this.itemTypeIds)
  311. let lv = "";
  312. if (typeof this.itemTypeIds === "object") {
  313. lv = this.itemTypeIds[this.itemTypeIds.length - 1];
  314. }
  315. if (lv) {
  316. this.dict.asbItem = arrayFilter(this.dict.asbItemAll, "itemTypeId", lv);
  317. } else {
  318. this.dict.asbItem = [...this.dict.asbItemAll];
  319. }
  320. console.log('lv,this.dict.asbItem', lv, this.dict.asbItem)
  321. },
  322. //按项目类别显示组合项目,并过滤已选择的组合项目
  323. getAsbItemByItemType() {
  324. this.getAsbItemByItemTypeAll()
  325. //刷新显示 未选组合项目
  326. arrayReduce(this.dict.asbItem, [...this.patientRegister.patientRegisterAbs], "id=asbitemId");
  327. },
  328. //体检登记的组合项目创建
  329. // registerAsbitem(body) {
  330. // console.log("registerAsbitem");
  331. // postapi(
  332. // `/api/app/register-asbitem?CustomerOrgId=${this.patientRegisterForm.customerOrgId}`,
  333. // body
  334. // ).then((res) => {
  335. // console.log("medicalPackageAsb", res);
  336. // if (res.code == 1) {
  337. // //未选项目中移除,已选项中添加
  338. // }
  339. // });
  340. // },
  341. //选中分组所包含的组合项目
  342. getCustomerOrgGroupAsb(customerOrgGroupId) {
  343. console.log(`getCustomerOrgGroupAsb /api/app/customer-org-group-detail/customer-org-group-detail-in-asbitem/${customerOrgGroupId}`);
  344. getapi(`/api/app/customer-org-group-detail/customer-org-group-detail-in-asbitem/${customerOrgGroupId}`)
  345. .then((res) => {
  346. console.log("getCustomerOrgGroupAsb", res);
  347. if (res.code == 1) {
  348. this.patientRegister.customerOrgGroupAsb = res.data;
  349. //移除旧分组或套餐的组合项目
  350. this.removeGroupPackageAsb();
  351. //添加新分组的组合项目;
  352. this.addCustomerOrgGroupAsb(customerOrgGroupId);
  353. }
  354. });
  355. },
  356. //选中套餐所包含的组合项目
  357. getMedicalPackageAsb(medicalPackageId) {
  358. console.log(`/api/app/medical-package-detail/medical-package-in-asbitem?MedicalPackageId=${medicalPackageId}`);
  359. getapi(`/api/app/medical-package-detail/medical-package-in-asbitem?MedicalPackageId=${medicalPackageId}`)
  360. .then((res) => {
  361. console.log("getMedicalPackageAsb", res);
  362. if (res.code == 1) {
  363. this.patientRegister.medicalPackageAsb = res.data;
  364. //移除旧分组或套餐的组合项目
  365. this.removeGroupPackageAsb();
  366. //添加新套餐的组合项目
  367. this.addMedicalPackageAsb(medicalPackageId);
  368. }
  369. });
  370. },
  371. //添加新分组的组合项目
  372. async addCustomerOrgGroupAsb(groupPackageId) {
  373. let body = []
  374. let payTypeFlag = '0'
  375. let lfind = -1
  376. let editCount = 0
  377. if (this.patientRegisterForm.customerOrgId != this.dict.personOrgId) payTypeFlag = '1'
  378. console.log('this.patientRegister.customerOrgGroupAsb', this.patientRegister.customerOrgGroupAsb)
  379. for (let i = 0; i < this.patientRegister.customerOrgGroupAsb.length; i++) {
  380. lfind = arrayExistObj(this.patientRegister.patientRegisterAbs, 'asbitemId', this.patientRegister.customerOrgGroupAsb[i].asbitemId)
  381. if (lfind > - 1) {
  382. this.patientRegister.patientRegisterAbs[lfind].groupPackageId = groupPackageId
  383. continue
  384. }
  385. let pojo = {
  386. asbitemId: this.patientRegister.customerOrgGroupAsb[i].asbitemId,
  387. patientRegisterId: this.patientRegisterForm.id,
  388. standardPrice: this.patientRegister.customerOrgGroupAsb[i].price,
  389. chargePrice: this.patientRegister.customerOrgGroupAsb[i].customerOrgGroupDetailPrice,
  390. payTypeFlag,
  391. isCharge: "N",
  392. amount: 1,
  393. groupPackageId: groupPackageId
  394. }
  395. body.push(pojo)
  396. this.patientRegister.patientRegisterAbs.push({ ...pojo, asbitemName: this.patientRegister.customerOrgGroupAsb[i].displayName })
  397. }
  398. console.log('this.patientRegister.patientRegisterAbs', this.patientRegister.patientRegisterAbs)
  399. // if (editCount > 0 && this.patientRegisterForm.id) await this.onSubmit('');
  400. // if (body.length > 0 && this.patientRegisterForm.id) {
  401. // await this.batchAddAsb(body, '更换分组');
  402. // } else {
  403. // //刷新
  404. // this.getAsbItemByItemType()
  405. // }
  406. if(this.patientRegister.patientRegisterAbs.length > 0 && this.patientRegisterForm.id){
  407. await this.onSubmit('更换分组');
  408. }
  409. },
  410. //添加新套餐的组合项目
  411. async addMedicalPackageAsb(groupPackageId) {
  412. let body = []
  413. let payTypeFlag = '0'
  414. let lfind = -1
  415. let editCount = 0
  416. if (this.patientRegisterForm.customerOrgId != this.dict.personOrgId) payTypeFlag = '1'
  417. for (let i = 0; i < this.patientRegister.medicalPackageAsb.length; i++) {
  418. lfind = arrayExistObj(this.patientRegister.patientRegisterAbs, 'asbitemId', this.patientRegister.medicalPackageAsb[i].id)
  419. if (lfind > - 1) {
  420. this.patientRegister.patientRegisterAbs[lfind].groupPackageId = groupPackageId
  421. editCount++
  422. continue
  423. }
  424. let pojo = {
  425. asbitemId: this.patientRegister.medicalPackageAsb[i].id,
  426. patientRegisterId: this.patientRegisterForm.id,
  427. standardPrice: this.patientRegister.medicalPackageAsb[i].price,
  428. chargePrice: this.patientRegister.medicalPackageAsb[i].price,
  429. payTypeFlag,
  430. isCharge: "N",
  431. amount: 1,
  432. groupPackageId: groupPackageId
  433. }
  434. body.push(pojo)
  435. this.patientRegister.patientRegisterAbs.push({ ...pojo, asbitemName: this.patientRegister.customerOrgGroupAsb[i].displayName })
  436. }
  437. if (editCount > 0 && this.patientRegisterForm.id) await this.onSubmit('');
  438. if (body.length > 0 && this.patientRegisterForm.id) {
  439. await this.batchAddAsb(body, '更换分组');
  440. } else {
  441. //刷新
  442. this.getAsbItemByItemType()
  443. }
  444. },
  445. //移除旧分组或套餐的组合项目
  446. async removeGroupPackageAsb() {
  447. let body = {}
  448. let registerAsbitemIds = []
  449. let chargeComplete = ''
  450. //体检基本信息未保存时,删除所有所选项目
  451. if (!this.patientRegisterForm.id) {
  452. this.patientRegister.patientRegisterAbs = []
  453. return
  454. }
  455. //删除已选 分组或套餐的组合项目 ,如已收费或 已检时,将 groupPackageId 置为null
  456. for (let i = 0; i < this.patientRegister.patientRegisterAbs.length; i++) {
  457. if (!this.patientRegister.patientRegisterAbs[i].id) {
  458. this.patientRegister.patientRegisterAbs.splice(i, 1)
  459. i--
  460. continue
  461. }
  462. if (this.patientRegister.patientRegisterAbs[i].isCharge == 'Y' || this.patientRegister.patientRegisterAbs[i].checkCompleteFlag != '0') {
  463. chargeComplete += this.patientRegister.patientRegisterAbs[i].asbitemName + ','
  464. this.patientRegister.patientRegisterAbs[i].groupPackageId = null
  465. } else {
  466. //数据库有,才添加到待删除的数组中
  467. if (this.patientRegister.patientRegisterAbs[i].id) {
  468. registerAsbitemIds.push(this.patientRegister.patientRegisterAbs[i].id)
  469. }
  470. this.patientRegister.patientRegisterAbs.splice(i, 1)
  471. i--
  472. }
  473. }
  474. if (chargeComplete) {
  475. this.$message({ type: "info", message: `所选项目:${chargeComplete}已收费或已检,不可删除!` });
  476. }
  477. body = { registerAsbitemIds }
  478. if (registerAsbitemIds.length > 0) {
  479. await this.batchDelAsb(body, '');
  480. }
  481. let updateBody = []
  482. if (this.patientRegister.patientRegisterAbs.length > 0) {
  483. for (let i = 0; i < this.patientRegister.patientRegisterAbs.length; i++) {
  484. //数据库有,才添加到待更新的数组中
  485. if (this.patientRegister.patientRegisterAbs[i].id) {
  486. updateBody.push({
  487. registerAsbitemId: this.patientRegister.patientRegisterAbs[i].id,
  488. input: {
  489. chargePrice: this.patientRegister.patientRegisterAbs[i].chargePrice,
  490. payTypeFlag: this.patientRegister.patientRegisterAbs[i].payTypeFlag,
  491. isCharge: this.patientRegister.patientRegisterAbs[i].isCharge,
  492. amount: this.patientRegister.patientRegisterAbs[i].amount,
  493. groupPackageId: this.patientRegister.patientRegisterAbs[i].groupPackageId
  494. }
  495. })
  496. }
  497. }
  498. await this.batchEditAsb(updateBody, '');
  499. }
  500. },
  501. //自定义计算列
  502. getSummaries(param) {
  503. const { columns, data } = param;
  504. const sumCol = [2,4] //需合计的列
  505. const sums = [];
  506. columns.forEach((column, index) => {
  507. //显示合计列
  508. if (index === 1) {
  509. sums[index] = '合计';
  510. return;
  511. }
  512. //不合计的列
  513. if (sumCol.indexOf(index) == -1) {
  514. sums[index] = '';
  515. return;
  516. }
  517. const values = data.map(item => Number(item[column.property]));
  518. if (!values.every(value => isNaN(value))) {
  519. sums[index] = values.reduce((prev, curr) => {
  520. const value = Number(curr);
  521. if (!isNaN(value)) {
  522. return prev + curr;
  523. } else {
  524. return prev;
  525. }
  526. }, 0);
  527. sums[index] += ' 元';
  528. } else {
  529. sums[index] = 'N/A';
  530. }
  531. });
  532. return sums;
  533. },
  534. },
  535. //监听事件
  536. watch: {
  537. //分组改变,查出当前分组下对应的组合项目
  538. "patientRegister.customerOrgGroupChange"(newVal, oldVal) {
  539. console.log("watch patientRegister.customerOrgGroupChange newVal:", newVal, " oldVal:", oldVal);
  540. if (newVal != oldVal && newVal > 0) {
  541. this.getCustomerOrgGroupAsb(this.patientRegisterForm.customerOrgGroupId);
  542. }
  543. },
  544. //套餐改变,查出当前套餐下对应的组合项目
  545. "patientRegister.medicalPackageChange"(newVal, oldVal) {
  546. console.log("watch patientRegister.medicalPackageChange newVal:", newVal, " oldVal:", oldVal);
  547. if (newVal != oldVal && newVal > 0) {
  548. this.getMedicalPackageAsb(this.patientRegisterForm.medicalPackageId);
  549. }
  550. },
  551. //体检信息触发分组的保存
  552. "patientRegister.saveTimes"(newVal, oldVal) {
  553. this.onSubmit('')
  554. },
  555. },
  556. };
  557. </script>
  558. <style scoped>
  559. .mainareaBox {
  560. border: 1px solid #000;
  561. height: 200px;
  562. margin-top: 10px;
  563. }
  564. .mainbutton {
  565. display: flex;
  566. margin-left: 20px;
  567. padding: 5px 10px;
  568. margin-top: 10px;
  569. }
  570. </style>