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.

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