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.

741 lines
26 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 weeks ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
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 year ago
2 years ago
2 years ago
2 years ago
2 weeks ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 weeks ago
2 years ago
2 years ago
2 years ago
2 weeks ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
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 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 years ago
2 weeks ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 weeks ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 weeks ago
2 years ago
2 weeks ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
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. <div>
  4. <div class="contenttitle">
  5. 体检登记 /<span class="contenttitleBold">单位分组</span>
  6. </div>
  7. <!--分组信息-->
  8. <div style="display: flex; font-size: 14px">
  9. <div :style="'display: block;width:' + (window.pageWidth - window.pageMarginWidth - 110 - 5) + 'px;'">
  10. <div style="display: flex">
  11. <div>
  12. <span>体检单位</span>
  13. <el-select v-model="customerOrgId" placeholder="请选择体检单位" :filter-method="filterMethod"
  14. default-first-option clearable filterable @clear="customerOrg = deepCopy(customerOrgAll)"
  15. style="margin-left: 10px" @change="changeCustomerOrg" size="small">
  16. <el-option v-for="item in customerOrg" :key="item.id" :label="item.displayName" :value="item.id">
  17. {{ item.displayName }}
  18. </el-option>
  19. </el-select>
  20. </div>
  21. <div style="margin-left: 20px">
  22. <span>单位体检次数</span>
  23. <el-select v-model="customerOrgRegister" placeholder="次数" style="width: 60px; margin-left: 10px"
  24. size="small" @change="changeTimes" value-key="id">
  25. <el-option v-for="item in customerOrgRegisterList" :key="item.id" :label="item.medicalTimes"
  26. :value="item" />
  27. </el-select>
  28. </div>
  29. </div>
  30. <div>
  31. <el-table :data="customerOrgGroups" ref="customerOrgGroups" style="margin-top: 2px" row-key="id" border
  32. height="240px" size="small" highlight-current-row :row-class-name="handleRowClassName"
  33. @row-click="rowClick" id="customerOrgGroups">
  34. <el-table-column type="index" label="序号" width="50" align="center" />
  35. <el-table-column label="id" prop="id" min-width="200" align="center" />
  36. <el-table-column prop="displayName" label="名称" min-width="150" />
  37. <el-table-column prop="price" label="价格" min-width="60" align="center" />
  38. <el-table-column prop="canAddMoney" label="可自选金额" min-width="80" align="center" />
  39. <el-table-column prop="forSexId" label="适用性别" min-width="60" align="center">
  40. <template slot-scope="scope">
  41. {{ dddw(dict.forSex, "id", scope.row.forSexId, "displayName") }}
  42. </template>
  43. </el-table-column>
  44. <el-table-column prop="maritalStatusId" label="适用婚姻状况" min-width="80" align="center">
  45. <template slot-scope="scope">
  46. {{
  47. dddw(
  48. dict.forMaritalStatus,
  49. "id",
  50. scope.row.maritalStatusId,
  51. "displayName"
  52. )
  53. }}
  54. </template>
  55. </el-table-column>
  56. <el-table-column prop="creatorName" label="创建者" min-width="60" align="center" />
  57. <el-table-column label="创建时间" min-width="150" align="center">
  58. <template slot-scope="scope">
  59. {{ scope.row.creationTime ? moment(scope.row.creationTime).format("yyyy-MM-DD HH:mm:ss") : "" }}
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="操作" align="center">
  63. <template>
  64. <el-tag class="move" style="
  65. cursor: move;
  66. background-color: rgb(245, 245, 245);
  67. border: none;
  68. " draggable="true">
  69. <i class="el-icon-d-caret" style="width: 1rem; height: 1rem; color: rgb(113, 113, 113)"></i>
  70. </el-tag>
  71. </template>
  72. </el-table-column>
  73. </el-table>
  74. </div>
  75. </div>
  76. <!--按钮-->
  77. <div style="display: block; margin-left: 5px">
  78. <div v-show="checkPagePriv(pagePriv.privs, '复制上次分组')" style="margin-top: 0px">
  79. <el-button class="commonbutton" @click="btnCopyPreGroup">复制上次分组</el-button>
  80. </div>
  81. <div v-show="checkPagePriv(pagePriv.privs, '新增')" style="margin-top: 5px">
  82. <el-button class="commonbutton" @click="btnAdd('')">新增</el-button>
  83. </div>
  84. <div v-show="checkPagePriv(pagePriv.privs, '编辑')" style="margin-top: 5px">
  85. <el-button class="commonbutton" @click="btnEdit">编辑</el-button>
  86. </div>
  87. <div v-show="checkPagePriv(pagePriv.privs, '删除')" style="margin-top: 5px">
  88. <el-button class="deleteButton" @click="btnDel">删除</el-button>
  89. </div>
  90. <div v-show="checkPagePriv(pagePriv.privs, '置顶')" style="margin-top: 5px">
  91. <el-button class="commonbutton" @click="btnSetTop">置顶</el-button>
  92. </div>
  93. <div v-show="checkPagePriv(pagePriv.privs, '置底')" style="margin-top: 5px">
  94. <el-button class="commonbutton" @click="btnSetBottom">置底</el-button>
  95. </div>
  96. <div v-show="checkPagePriv(pagePriv.privs, '保存排序')" style="margin-top: 5px">
  97. <el-button class="commonbutton" @click="btnSort" :disabled="!isDrag">保存排序</el-button>
  98. </div>
  99. <div style="margin-top: 5px">
  100. <el-button class="commonbutton" @click="btnExport('customerOrgGroups')">导出分组</el-button>
  101. </div>
  102. </div>
  103. </div>
  104. <!--分组项目信息 -->
  105. <div>
  106. <CustomerOrgGroupAsbitem :customerOrgGroup="curCustomerOrgGroup" :curOrgGroups="customerOrgGroups"
  107. :customerOrgAll="customerOrgAll" :curOrgRegister="customerOrgRegister"
  108. :curOrgRegisterList="customerOrgRegisterList" :refreshMoney="refreshMoney" />
  109. </div>
  110. </div>
  111. <!-- 新增或者编辑弹框 -->
  112. <el-dialog :title="dataTransOpts.tableS.customer_org_group.id ? '编辑' : '新增'" :close-on-click-modal="false"
  113. :visible.sync="dialogWin.CustomerOrgGroupEdit" width="800px" @close="close_dialogWinCustomerOrgGroupEdit">
  114. <CustomerOrgGroupEdit :params="CustomerOrgGroupEditParams" />
  115. </el-dialog>
  116. <!-- -->
  117. </div>
  118. </template>
  119. <script>
  120. import moment from "moment";
  121. import FileSaver from 'file-saver';
  122. import Sortable from "sortablejs";
  123. import { getapi, postapi, putapi, deletapi } from "@/api/api";
  124. import { mapState } from "vuex";
  125. import {
  126. getPagePriv,
  127. checkPagePriv,
  128. dddw,
  129. deepCopy,
  130. objCopy,
  131. arrayExistObj,
  132. } from "../../utlis/proFunc";
  133. import CustomerOrgGroupAsbitem from "../../components/customerOrg/customerOrgGroupAsbitem.vue";
  134. import CustomerOrgGroupEdit from "./CustomerOrgGroupEdit.vue";
  135. import { setDBCom, getDBCom } from "../../utlis/indexedDB";
  136. export default {
  137. components: {
  138. CustomerOrgGroupAsbitem, CustomerOrgGroupEdit
  139. },
  140. data() {
  141. return {
  142. pagePriv: {
  143. routeUrlorPageName: "customerOrgGroup", //当前页面归属路由或归属页面权限名称
  144. privs: [], // 页面权限
  145. },
  146. customerOrgAll: [], // 所有顶级单位
  147. customerOrg: [], //体检单位
  148. customerOrgGroups: [], //体检单位分组
  149. customerOrgId: "", //当前选中的体检单位id
  150. customerOrgRegisterList: [], //体检次数列表
  151. customerOrgRegister: {}, //体检次数
  152. curCustomerOrgGroup: {}, // 当前选中分组
  153. CustomerOrgGroupEditParams: {}, //分组 新增时 用到参数
  154. isDrag: false,
  155. form: {
  156. //体检单位分组
  157. customerOrgId: "", //复制分组时用到(预留查历次分组)
  158. isComplete: "N", //体检次数是否完成,如完成不允许调整分组项目
  159. id: "",
  160. customerOrgRegisterId: null, //所属体检次数
  161. displayName: "",
  162. price: 0,
  163. forSexId: "A",
  164. maritalStatusId: "A",
  165. ageLowerLimit: 0,
  166. ageUpperLimit: 200,
  167. jobPost: "",
  168. jobTitle: "",
  169. remark: "",
  170. isMaxMedicalTimes: "N",
  171. },
  172. formOri: {}, //用于对比分析哪些信息更改了
  173. formInit: {}, //表单初始值
  174. rules: {
  175. displayName: [{ required: true, message: "请填写分组名称", trigger: "blur" }],
  176. },
  177. };
  178. },
  179. computed: {
  180. ...mapState(["personnelUnit", "window", "dict", "dialogWin", "dataTransOpts"]),
  181. },
  182. created() {
  183. //获取用户当前页面的权限
  184. let userPriv = window.sessionStorage.getItem("userPriv");
  185. if (userPriv)
  186. this.pagePriv.privs = deepCopy(getPagePriv(this.pagePriv.routeUrlorPageName));
  187. // 清除当前选中的分组ID
  188. this.dataTransOpts.tableS.customer_org_group.id = ''
  189. this.rowDrop();
  190. this.formInit = deepCopy(this.form);
  191. },
  192. mounted() {
  193. //获取初始数据(单位、适用性别)
  194. this.dictInit();
  195. },
  196. methods: {
  197. moment,
  198. checkPagePriv,
  199. dddw,
  200. deepCopy,
  201. // 复制上一次分组
  202. btnCopyPreGroup() {
  203. if (!this.customerOrgRegister.id) {
  204. this.$message.warning("请选择体检次数");
  205. return;
  206. }
  207. postapi('/api/app/CustomerOrgGroup/CopyLastGrouping', { customerOrgRegisterId: this.customerOrgRegister.id })
  208. .then(res => {
  209. if (res.code > -1) {
  210. // 刷新体检次数的分组
  211. this.getCustomerOrgGroup(this.customerOrgRegister.id);
  212. }
  213. })
  214. },
  215. //刷新分组价格(供子组件调用)
  216. refreshMoney(formData) {
  217. //console.log('this is parent')
  218. let lfind = arrayExistObj(this.customerOrgGroups, "id", formData.id);
  219. if (lfind > -1) this.customerOrgGroups[lfind].price = formData.price;
  220. },
  221. //确定排序
  222. btnSort() {
  223. const result = [];
  224. this.customerOrgGroups.forEach((item, index) => {
  225. result.push({ id: item.id, displayOrder: index });
  226. });
  227. putapi("/api/app/customerorggroup/updatesortmany", {
  228. itemList: result,
  229. }).then((res) => {
  230. console.log("操作成功");
  231. this.isDrag = false;
  232. });
  233. },
  234. //通用导出
  235. btnExport(elId) {
  236. // 获取HTML元素(表格)
  237. // let table = document.getElementById(elId); //.cloneNode(true)
  238. this.$nextTick(() => {
  239. // let refsTable = this.$refs[elId] //.cloneNode(true) true
  240. let table = document.getElementById(elId)
  241. // console.log('table,refsTable', table, refsTable)
  242. let tableData = table.innerHTML
  243. let fileName = moment(new Date()).format('yyyyMMDDHHmmss')
  244. let blob = new Blob([tableData], { type: "text/plain;charset=utf-8" });
  245. FileSaver.saveAs(blob, fileName + '.xls');
  246. // 导出图片
  247. // 使用html2canvas将HTML元素转换为画布
  248. // let cloneTable = table.cloneNode(true) //[elId]
  249. /*
  250. html2canvas(table).then(canvas => {
  251. // 创建一个a元素用于下载
  252. const link = document.createElement('a');
  253. link.href = canvas.toDataURL('image/jpeg');
  254. link.download = fileName + '.jpg';
  255. document.body.appendChild(link);
  256. link.click();
  257. //document.body.removeChild(link);
  258. // // 创建一个PDF对象
  259. // var pdf = new jsPDF();
  260. // // 设置PDF的尺寸
  261. // pdf.addImage(canvas.toDataURL('image/png'), 'PNG', 0, 0, canvas.width, canvas.height);
  262. // // 导出PDF
  263. // pdf.save('员工信息表.pdf');
  264. });
  265. */
  266. })
  267. },
  268. //初始化Sortable组件
  269. rowDrop() {
  270. // this.$nextTick(() => {
  271. // const tbody = document.querySelector(".el-table__body-wrapper tbody");
  272. // const _this = this;
  273. // Sortable.create(tbody, {
  274. // handle: ".move",
  275. // animation: 300,
  276. // onEnd({ newIndex, oldIndex }) {
  277. // _this.isDrag = false;
  278. // const currRow = _this.customerOrgGroups.splice(oldIndex, 1)[0];
  279. // _this.customerOrgGroups.splice(newIndex, 0, currRow);
  280. // _this.customerOrgGroups.map((item, index) => {
  281. // if (index == newIndex && index == oldIndex) {
  282. // } else if (index == oldIndex) {
  283. // } else if (index == newIndex) {
  284. // }
  285. // });
  286. // console.log(_this.customerOrgGroups.map((item) => item.displayOrder));
  287. // },
  288. // });
  289. // });
  290. this.$nextTick(() => {
  291. const el = document.querySelector(".el-table__body-wrapper tbody");
  292. //console.log('el0',el)
  293. const that = this;
  294. Sortable.create(el, {
  295. handle: ".move",
  296. animation: 300,
  297. //拖拽结束
  298. onEnd({ newIndex, oldIndex }) {
  299. that.isDrag = true;
  300. const currRow = that.customerOrgGroups.splice(oldIndex, 1)[0];
  301. that.customerOrgGroups.splice(newIndex, 0, currRow);
  302. console.log("el", el);
  303. },
  304. });
  305. });
  306. },
  307. //置底
  308. btnSetBottom() {
  309. if (!this.dataTransOpts.tableS.customer_org_group.id) {
  310. this.$message.warning("请选择操作的数据");
  311. return;
  312. }
  313. let lfind = arrayExistObj(this.customerOrgGroups, "id", this.dataTransOpts.tableS.customer_org_group.id);
  314. let currentRow = {};
  315. putapi(
  316. `/api/app/customerorggroup/updatemanysort?id=${this.dataTransOpts.tableS.customer_org_group.id}&SortType=2`
  317. ).then((res) => {
  318. console.log("操作成功");
  319. currentRow = this.customerOrgGroups.splice(lfind, 1)[0]; //删除并赋值
  320. this.customerOrgGroups.push(currentRow);
  321. this.$refs["customerOrgGroups"].setCurrentRow(currentRow);
  322. });
  323. },
  324. //置顶
  325. btnSetTop() {
  326. if (!this.dataTransOpts.tableS.customer_org_group.id) {
  327. this.$message.warning("请选择操作的数据");
  328. return;
  329. }
  330. let lfind = arrayExistObj(this.customerOrgGroups, "id", this.dataTransOpts.tableS.customer_org_group.id);
  331. let currentRow = {};
  332. putapi(
  333. `/api/app/customerorggroup/updatemanysort?id=${this.dataTransOpts.tableS.customer_org_group.id}&SortType=1`
  334. ).then((res) => {
  335. console.log("操作成功");
  336. currentRow = this.customerOrgGroups.splice(lfind, 1)[0];
  337. this.customerOrgGroups.unshift(currentRow);
  338. this.$refs["customerOrgGroups"].setCurrentRow(currentRow);
  339. });
  340. },
  341. //选中颜色
  342. handleRowClassName({ row, rowIndex }) {
  343. // highLightBg 为 'selected'的高亮
  344. //console.log(rowIndex, row)
  345. //return row.highLightBg == 'selected' ? 'high-light-bg' : '';
  346. if (row.choosed) {
  347. return "current-row";
  348. } else {
  349. return "";
  350. }
  351. },
  352. // 获取顶级单位
  353. getOrg1() {
  354. getDBCom('orgDatas1')
  355. .then(localData => {
  356. let now = Date.now()
  357. // 24小时 = 86400000 毫秒
  358. if (localData?.createdat && localData.data.length > 0 && now - 43200000 < localData.createdat) {
  359. this.customerOrgAll = localData.data
  360. this.customerOrg = this.customerOrgAll.slice(0,20)
  361. } else {
  362. this.getOrg1Api()
  363. }
  364. })
  365. .catch(err => {
  366. console.error(err)
  367. this.getOrg1Api()
  368. })
  369. },
  370. getOrg1Api() {
  371. postapi("/api/app/CustomerOrg/GetParentCustomerOrgSimple", { isPerson: 'N' }).then((res) => {
  372. if (res.code != -1) {
  373. this.customerOrgAll = res.data;
  374. // let lfind = arrayExistObj(this.customerOrgAll, "id", this.dict.personOrgId);
  375. // if (lfind > -1) this.customerOrgAll.splice(lfind, 1);
  376. this.customerOrg = this.customerOrgAll.slice(0, 20)
  377. setDBCom('orgDatas1', this.customerOrgAll) // 一级单位
  378. }
  379. });
  380. },
  381. //获取初始数据
  382. dictInit() {
  383. this.getOrg1()
  384. //获取适用性别
  385. getapi("/api/app/for-sex").then((res) => {
  386. if (res.code != -1) {
  387. this.dict.forSex = res.data;
  388. }
  389. });
  390. //获取适用婚姻
  391. postapi("/api/app/MaritalStatus/GetForMaritalStatusList").then((res) => {
  392. if (res.code != -1) {
  393. this.dict.forMaritalStatus = res.data;
  394. }
  395. });
  396. },
  397. //获取体检次数下的分组
  398. getCustomerOrgGroup(customerOrgRegisterId) {
  399. this.isDrag = false;
  400. objCopy(this.formInit, this.form);
  401. this.form.customerOrgRegisterId = customerOrgRegisterId;
  402. this.customerOrgGroups = [];
  403. getapi(
  404. `/api/app/customerorggroup/getlistinfilter?CustomerOrgRegisterId=${customerOrgRegisterId}`
  405. ).then((res) => {
  406. if (res.code != -1) {
  407. this.customerOrgGroups = res.data;
  408. this.customerOrgGroups.forEach((e) => {
  409. e.customerOrgRegisterId = customerOrgRegisterId;
  410. });
  411. }
  412. });
  413. },
  414. filterMethod(keyWords) {
  415. if (keyWords) {
  416. let org = this.customerOrgAll.filter(e => {
  417. })
  418. this.customerOrg = [];
  419. this.customerOrgAll.forEach((item) => {
  420. if (
  421. item.displayName.toLowerCase().indexOf(keyWords.toLowerCase()) > -1 ||
  422. item.simpleCode.toLowerCase().indexOf(keyWords.toLowerCase()) > -1
  423. // || item.shortName.toLowerCase().indexOf(keyWords.toLowerCase()) > - 1
  424. ) {
  425. this.customerOrg.push(item);
  426. }
  427. });
  428. } else {
  429. this.customerOrg = this.customerOrgAll.slice(0,20);
  430. }
  431. },
  432. //选择单位
  433. changeCustomerOrg(v) {
  434. if (!v) {
  435. this.customerOrgRegisterList = [];
  436. this.customerOrgRegister = {};
  437. this.customerOrgGroups = [];
  438. this.isDrag = false;
  439. this.form.id = "";
  440. setTimeout(() => {
  441. this.dataTransOpts.refresh.customer_org_group_detail.M++;
  442. }, 20);
  443. return;
  444. }
  445. getapi(
  446. `/api/app/customerorgregister/getlistincustomerorgid?CustomerOrgId=${v}`
  447. ).then((res) => {
  448. if (res.code != -1) {
  449. this.customerOrgRegisterList = res.data;
  450. if (res.data.length > 0) {
  451. this.customerOrgRegister = res.data[res.data.length - 1];
  452. this.getCustomerOrgGroup(this.customerOrgRegister.id);
  453. } else {
  454. this.customerOrgRegister = {};
  455. this.customerOrgGroups = [];
  456. this.isDrag = false;
  457. }
  458. objCopy(this.formInit, this.form);
  459. setTimeout(() => {
  460. this.dataTransOpts.refresh.customer_org_group_detail.M++;
  461. }, 20);
  462. }
  463. });
  464. },
  465. //选择体检次数
  466. changeTimes(v) {
  467. this.getCustomerOrgGroup(v.id);
  468. },
  469. //点击分组
  470. rowClick(row) {
  471. this.dataTransOpts.tableS.customer_org_group.id = row.id
  472. this.curCustomerOrgGroup = deepCopy(row);
  473. this.curCustomerOrgGroup.isComplete = this.customerOrgRegister.isComplete;
  474. setTimeout(() => {
  475. this.dataTransOpts.refresh.customer_org_group_detail.M++;
  476. }, 20);
  477. },
  478. // 新增(编辑调用时,传入id值) 弹框
  479. btnAdd(id) {
  480. if (!this.customerOrgRegister.id) {
  481. this.$message.warning("请选择体检次数");
  482. return;
  483. }
  484. if (this.customerOrgRegister.isComplete.toUpperCase() == "Y") {
  485. this.$message.warning(`该单位的该次体检次数已完成,不能再${id ? '编辑' : '新增'}分组!`);
  486. return;
  487. }
  488. if (!id) this.dataTransOpts.tableS.customer_org_group.id = ''
  489. setTimeout(() => {
  490. this.dataTransOpts.refresh.customer_org_group.S++
  491. if (!id) this.dataTransOpts.refresh.customer_org_group_detail.M++; //新增则清掉已选组合项目
  492. }, 20);
  493. this.CustomerOrgGroupEditParams = {
  494. customerOrgRegisterId: this.customerOrgRegister.id,
  495. customerOrgId: this.customerOrgId
  496. }
  497. this.dialogWin.CustomerOrgGroupEdit = true;
  498. },
  499. //编辑弹框
  500. btnEdit() {
  501. if (!this.dataTransOpts.tableS.customer_org_group.id) {
  502. this.$message.warning("请先选择体检分组");
  503. return;
  504. }
  505. this.btnAdd(this.dataTransOpts.tableS.customer_org_group.id)
  506. },
  507. //删除
  508. btnDel() {
  509. if (!this.dataTransOpts.tableS.customer_org_group.id) {
  510. this.$message.warning("请选择需要操作的数据");
  511. return;
  512. }
  513. if (this.customerOrgRegister.isComplete.toUpperCase() == "Y") {
  514. this.$message.warning("该单位体检次数已完成,不允许删除分组");
  515. return;
  516. }
  517. this.$confirm("此操作将永久删除该记录, 是否继续?", "提示", {
  518. confirmButtonText: "是",
  519. cancelButtonText: " 否 ",
  520. type: "warning",
  521. })
  522. .then(() => {
  523. return deletapi(`/api/app/customer-org-group/${this.dataTransOpts.tableS.customer_org_group.id}`);
  524. })
  525. .then((res) => {
  526. if (res.code != -1) {
  527. console.log("删除成功");
  528. let lfind = arrayExistObj(this.customerOrgGroups, "id", this.dataTransOpts.tableS.customer_org_group.id);
  529. if (lfind > -1) this.customerOrgGroups.splice(lfind, 1);
  530. this.dataTransOpts.tableS.customer_org_group.id = ''
  531. setTimeout(() => {
  532. this.dataTransOpts.refresh.customer_org_group_detail.M++
  533. }, 20);
  534. }
  535. })
  536. .catch((err) => {
  537. if (err == "cancel") {
  538. console.log("已取消删除");
  539. // this.$message.info("已取消删除");
  540. }
  541. });
  542. },
  543. //计算总价
  544. computePrice() {
  545. if (!this.form.id) {
  546. this.$message.warning("尚未保存信息,不可执行此操作!");
  547. return;
  548. }
  549. let customerOrgGroupId = this.form.id;
  550. let customerOrgGroupAsbitems = []; //分组包含的套餐
  551. getapi(`/api/app/customerorggroupdetail/getcustomerorggroupdetailinasbitem?CustomerOrgGroupId=${customerOrgGroupId}
  552. `)
  553. .then((res) => {
  554. if (res.code != -1) {
  555. customerOrgGroupAsbitems = res.data;
  556. if (customerOrgGroupAsbitems.length < 1) {
  557. this.$message.warning("当前分组尚未设置组合项目,不可执行此操作!");
  558. } else {
  559. let body = {
  560. customerOrgGroupId,
  561. details: this.madeNewGroupAsbitems(
  562. customerOrgGroupAsbitems,
  563. this.form.price
  564. ),
  565. };
  566. console.log("body", body);
  567. return postapi(
  568. "/api/app/customerorggroupdetail/createcustomerorggroupdetailmany",
  569. body
  570. );
  571. }
  572. }
  573. })
  574. .then((res) => {
  575. if (res.code != -1) {
  576. //console.log("操作成功");
  577. //触发分组明细刷新
  578. this.form.id = "";
  579. //要做延时处理,否则不会触发监听
  580. setTimeout(() => {
  581. this.form.id = customerOrgGroupId;
  582. this.onSubmit("form");
  583. }, 100);
  584. }
  585. });
  586. },
  587. madeNewGroupAsbitems(oldGroupAsbitems, newTotal) {
  588. newTotal = Math.round(Number(newTotal) * 100) / 100;
  589. let newGroupAsbitems = [];
  590. let oldTotal = Number(0);
  591. oldGroupAsbitems.forEach((e) => {
  592. oldTotal += Number(e.asbitemMoney); //customerOrgGroupDetailMoney
  593. });
  594. oldTotal = Math.round(Number(oldTotal) * 100) / 100;
  595. let discount = 0;
  596. if (oldTotal != 0) discount = Math.round((newTotal * 10000) / oldTotal) / 100;
  597. oldTotal = Number(0);
  598. oldGroupAsbitems.forEach((e) => {
  599. e.customerOrgGroupDetailPrice = Math.round(e.price * discount) / 100;
  600. e.customerOrgGroupDetailMoney =
  601. Math.round(
  602. e.customerOrgGroupDetailPrice * e.customerOrgGroupDetailAmount * 100
  603. ) / 100;
  604. oldTotal += Number(e.customerOrgGroupDetailMoney);
  605. });
  606. oldTotal = Math.round(Number(oldTotal) * 100) / 100;
  607. //console.log('discount,oldTotal',discount,oldTotal)
  608. let didTotal = Math.round(Number(newTotal - oldTotal) * 100) / 100;
  609. if (didTotal != 0) {
  610. for (let i = 0; i < oldGroupAsbitems.length; i++) {
  611. if (oldGroupAsbitems[i].customerOrgGroupDetailAmount == 1) {
  612. oldGroupAsbitems[i].customerOrgGroupDetailPrice =
  613. Math.round(
  614. (Number(oldGroupAsbitems[i].customerOrgGroupDetailPrice) +
  615. Number(didTotal)) *
  616. 100
  617. ) / 100;
  618. break;
  619. }
  620. }
  621. }
  622. oldGroupAsbitems.forEach((e) => {
  623. newGroupAsbitems.push({
  624. customerOrgGroupId: e.customerOrgGroupId,
  625. asbitemId: e.asbitemId,
  626. price: e.customerOrgGroupDetailPrice,
  627. amount: e.customerOrgGroupDetailAmount,
  628. });
  629. });
  630. return newGroupAsbitems;
  631. },
  632. // 关闭 分组 新增/编辑
  633. close_dialogWinCustomerOrgGroupEdit() {
  634. let id = this.dataTransOpts.tableS.customer_org_group.id
  635. if (id) {
  636. // 点编辑 或 新增有提交
  637. getapi(`/api/app/customer-org-group/${id}`)
  638. .then(res => {
  639. if (res.code != -1) {
  640. let lfind = -1
  641. lfind = arrayExistObj(this.customerOrgGroups, 'id', id)
  642. if (lfind > -1) {
  643. objCopy(res.data, this.customerOrgGroups[lfind])
  644. } else {
  645. lfind = this.customerOrgGroups.length
  646. this.customerOrgGroups.push(res.data)
  647. }
  648. // 选中当前操作的列
  649. this.$refs["customerOrgGroups"].setCurrentRow(); //清除选择
  650. this.$refs["customerOrgGroups"].setCurrentRow(this.customerOrgGroups[lfind]);
  651. // 更新 customer_org_group_detail 参数
  652. this.curCustomerOrgGroup = deepCopy(res.data);
  653. this.curCustomerOrgGroup.isComplete = this.customerOrgRegister.isComplete;
  654. }
  655. })
  656. } else {
  657. // 点 新增 但未提交
  658. this.dataTransOpts.tableS.customer_org_group.id = this.curCustomerOrgGroup.id || ''
  659. }
  660. this.dataTransOpts.refresh.customer_org_group_detail.M++;
  661. },
  662. },
  663. };
  664. </script>
  665. <style scoped>
  666. @import "../../assets/css/global_button.css";
  667. @import "../../assets/css/global_dialog.css";
  668. @import "../../assets/css/global_table.css";
  669. @import "../../assets/css/global_form.css";
  670. @import "../../assets/css/global_input.css";
  671. @import "../../assets/css/global.css";
  672. .btnClass {
  673. width: 100px;
  674. margin-bottom: 5px;
  675. }
  676. </style>