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.

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