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.

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