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.

661 lines
23 KiB

3 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
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 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
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 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
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 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
3 years ago
2 years ago
3 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
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 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
3 years ago
3 years ago
3 years ago
2 years ago
3 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. postapi('/api/app/CustomerOrgGroup/CopyLastGrouping', { customerOrgRegisterId: this.customerOrgRegister.id })
  199. .then(res => {
  200. if (res.code > -1) {
  201. // 刷新体检次数的分组
  202. this.getCustomerOrgGroup(this.customerOrgRegister.id);
  203. }
  204. })
  205. },
  206. //刷新分组价格(供子组件调用)
  207. refreshMoney(formData) {
  208. //console.log('this is parent')
  209. let lfind = arrayExistObj(this.customerOrgGroups, "id", formData.id);
  210. if (lfind > -1) this.customerOrgGroups[lfind].price = formData.price;
  211. },
  212. //确定排序
  213. btnSort() {
  214. const result = [];
  215. this.customerOrgGroups.forEach((item, index) => {
  216. result.push({ id: item.id, displayOrder: index });
  217. });
  218. putapi("/api/app/customerorggroup/updatesortmany", {
  219. itemList: result,
  220. }).then((res) => {
  221. console.log("操作成功");
  222. this.isDrag = false;
  223. });
  224. },
  225. //初始化Sortable组件
  226. rowDrop() {
  227. // this.$nextTick(() => {
  228. // const tbody = document.querySelector(".el-table__body-wrapper tbody");
  229. // const _this = this;
  230. // Sortable.create(tbody, {
  231. // handle: ".move",
  232. // animation: 300,
  233. // onEnd({ newIndex, oldIndex }) {
  234. // _this.isDrag = false;
  235. // const currRow = _this.customerOrgGroups.splice(oldIndex, 1)[0];
  236. // _this.customerOrgGroups.splice(newIndex, 0, currRow);
  237. // _this.customerOrgGroups.map((item, index) => {
  238. // if (index == newIndex && index == oldIndex) {
  239. // } else if (index == oldIndex) {
  240. // } else if (index == newIndex) {
  241. // }
  242. // });
  243. // console.log(_this.customerOrgGroups.map((item) => item.displayOrder));
  244. // },
  245. // });
  246. // });
  247. this.$nextTick(() => {
  248. const el = document.querySelector(".el-table__body-wrapper tbody");
  249. //console.log('el0',el)
  250. const that = this;
  251. Sortable.create(el, {
  252. handle: ".move",
  253. animation: 300,
  254. //拖拽结束
  255. onEnd({ newIndex, oldIndex }) {
  256. that.isDrag = true;
  257. const currRow = that.customerOrgGroups.splice(oldIndex, 1)[0];
  258. that.customerOrgGroups.splice(newIndex, 0, currRow);
  259. console.log("el", el);
  260. },
  261. });
  262. });
  263. },
  264. //置底
  265. btnSetBottom() {
  266. if (!this.dataTransOpts.tableS.customer_org_group.id) {
  267. this.$message.warning("请选择操作的数据");
  268. return;
  269. }
  270. let lfind = arrayExistObj(this.customerOrgGroups, "id", this.dataTransOpts.tableS.customer_org_group.id);
  271. let currentRow = {};
  272. putapi(
  273. `/api/app/customerorggroup/updatemanysort?id=${this.dataTransOpts.tableS.customer_org_group.id}&SortType=2`
  274. ).then((res) => {
  275. console.log("操作成功");
  276. currentRow = this.customerOrgGroups.splice(lfind, 1)[0]; //删除并赋值
  277. this.customerOrgGroups.push(currentRow);
  278. this.$refs["customerOrgGroups"].setCurrentRow(currentRow);
  279. });
  280. },
  281. //置顶
  282. btnSetTop() {
  283. if (!this.dataTransOpts.tableS.customer_org_group.id) {
  284. this.$message.warning("请选择操作的数据");
  285. return;
  286. }
  287. let lfind = arrayExistObj(this.customerOrgGroups, "id", this.dataTransOpts.tableS.customer_org_group.id);
  288. let currentRow = {};
  289. putapi(
  290. `/api/app/customerorggroup/updatemanysort?id=${this.dataTransOpts.tableS.customer_org_group.id}&SortType=1`
  291. ).then((res) => {
  292. console.log("操作成功");
  293. currentRow = this.customerOrgGroups.splice(lfind, 1)[0];
  294. this.customerOrgGroups.unshift(currentRow);
  295. this.$refs["customerOrgGroups"].setCurrentRow(currentRow);
  296. });
  297. },
  298. //选中颜色
  299. handleRowClassName({ row, rowIndex }) {
  300. // highLightBg 为 'selected'的高亮
  301. //console.log(rowIndex, row)
  302. //return row.highLightBg == 'selected' ? 'high-light-bg' : '';
  303. if (row.choosed) {
  304. return "current-row";
  305. } else {
  306. return "";
  307. }
  308. },
  309. //获取初始数据
  310. dictInit() {
  311. //获取单位列表
  312. getapi("/api/app/customer-org/parent-all").then((res) => {
  313. if (res.code != -1) {
  314. this.customerOrgAll = res.data;
  315. let lfind = arrayExistObj(this.customerOrgAll, "id", this.dict.personOrgId);
  316. if (lfind > -1) this.customerOrgAll.splice(lfind, 1);
  317. this.customerOrg = deepCopy(this.customerOrgAll);
  318. }
  319. });
  320. //获取适用性别
  321. getapi("/api/app/for-sex").then((res) => {
  322. if (res.code != -1) {
  323. this.dict.forSex = res.data;
  324. }
  325. });
  326. //获取适用婚姻
  327. postapi("/api/app/MaritalStatus/GetForMaritalStatusList").then((res) => {
  328. if (res.code != -1) {
  329. this.dict.forMaritalStatus = res.data;
  330. }
  331. });
  332. },
  333. //获取体检次数下的分组
  334. getCustomerOrgGroup(customerOrgRegisterId) {
  335. this.isDrag = false;
  336. objCopy(this.formInit, this.form);
  337. this.form.customerOrgRegisterId = customerOrgRegisterId;
  338. this.customerOrgGroups = [];
  339. getapi(
  340. `/api/app/customerorggroup/getlistinfilter?CustomerOrgRegisterId=${customerOrgRegisterId}`
  341. ).then((res) => {
  342. if (res.code != -1) {
  343. this.customerOrgGroups = res.data;
  344. this.customerOrgGroups.forEach((e) => {
  345. e.customerOrgRegisterId = customerOrgRegisterId;
  346. });
  347. }
  348. });
  349. },
  350. filterMethod(keyWords) {
  351. if (keyWords) {
  352. this.customerOrg = [];
  353. this.customerOrgAll.forEach((item) => {
  354. if (
  355. item.displayName.toLowerCase().indexOf(keyWords.toLowerCase()) > -1 ||
  356. item.simpleCode.toLowerCase().indexOf(keyWords.toLowerCase()) > -1
  357. // || item.shortName.toLowerCase().indexOf(keyWords.toLowerCase()) > - 1
  358. ) {
  359. this.customerOrg.push(item);
  360. }
  361. });
  362. } else {
  363. this.customerOrg = deepCopy(this.customerOrgAll);
  364. }
  365. },
  366. //选择单位
  367. changeCustomerOrg(v) {
  368. if (!v) {
  369. this.customerOrgRegisterList = [];
  370. this.customerOrgRegister = {};
  371. this.customerOrgGroups = [];
  372. this.isDrag = false;
  373. this.form.id = "";
  374. setTimeout(() => {
  375. this.dataTransOpts.refresh.customer_org_group_detail.M++;
  376. }, 20);
  377. return;
  378. }
  379. getapi(
  380. `/api/app/customerorgregister/getlistincustomerorgid?CustomerOrgId=${v}`
  381. ).then((res) => {
  382. if (res.code != -1) {
  383. this.customerOrgRegisterList = res.data;
  384. if (res.data.length > 0) {
  385. this.customerOrgRegister = res.data[res.data.length - 1];
  386. this.getCustomerOrgGroup(this.customerOrgRegister.id);
  387. } else {
  388. this.customerOrgRegister = {};
  389. this.customerOrgGroups = [];
  390. this.isDrag = false;
  391. }
  392. objCopy(this.formInit, this.form);
  393. setTimeout(() => {
  394. this.dataTransOpts.refresh.customer_org_group_detail.M++;
  395. }, 20);
  396. }
  397. });
  398. },
  399. //选择体检次数
  400. changeTimes(v) {
  401. this.getCustomerOrgGroup(v.id);
  402. },
  403. //点击分组
  404. rowClick(row) {
  405. this.dataTransOpts.tableS.customer_org_group.id = row.id
  406. this.curCustomerOrgGroup = deepCopy(row);
  407. this.curCustomerOrgGroup.isComplete = this.customerOrgRegister.isComplete;
  408. setTimeout(() => {
  409. this.dataTransOpts.refresh.customer_org_group_detail.M++;
  410. }, 20);
  411. },
  412. // 新增(编辑调用时,传入id值) 弹框
  413. btnAdd(id) {
  414. if (!this.customerOrgRegister.id) {
  415. this.$message.warning("请选择体检次数");
  416. return;
  417. }
  418. if (this.customerOrgRegister.isComplete.toUpperCase() == "Y") {
  419. this.$message.warning(`该单位的该次体检次数已完成,不能再${id ? '编辑' : '新增'}分组!`);
  420. return;
  421. }
  422. if (!id) this.dataTransOpts.tableS.customer_org_group.id = ''
  423. setTimeout(() => {
  424. this.dataTransOpts.refresh.customer_org_group.S++
  425. if (!id) this.dataTransOpts.refresh.customer_org_group_detail.M++; //新增则清掉已选组合项目
  426. }, 20);
  427. this.CustomerOrgGroupEditParams = {
  428. customerOrgRegisterId: this.customerOrgRegister.id,
  429. customerOrgId: this.customerOrgId
  430. }
  431. this.dialogWin.CustomerOrgGroupEdit = true;
  432. },
  433. //编辑弹框
  434. btnEdit() {
  435. if (!this.dataTransOpts.tableS.customer_org_group.id) {
  436. this.$message.warning("请先选择体检分组");
  437. return;
  438. }
  439. this.btnAdd(this.dataTransOpts.tableS.customer_org_group.id)
  440. },
  441. //删除
  442. btnDel() {
  443. if (!this.dataTransOpts.tableS.customer_org_group.id) {
  444. this.$message.warning("请选择需要操作的数据");
  445. return;
  446. }
  447. if (this.customerOrgRegister.isComplete.toUpperCase() == "Y") {
  448. this.$message.warning("该单位体检次数已完成,不允许删除分组");
  449. return;
  450. }
  451. this.$confirm("此操作将永久删除该记录, 是否继续?", "提示", {
  452. confirmButtonText: "是",
  453. cancelButtonText: " 否 ",
  454. type: "warning",
  455. })
  456. .then(() => {
  457. return deletapi(`/api/app/customer-org-group/${this.dataTransOpts.tableS.customer_org_group.id}`);
  458. })
  459. .then((res) => {
  460. if (res.code != -1) {
  461. console.log("删除成功");
  462. let lfind = arrayExistObj(this.customerOrgGroups, "id", this.dataTransOpts.tableS.customer_org_group.id);
  463. if (lfind > -1) this.customerOrgGroups.splice(lfind, 1);
  464. this.dataTransOpts.tableS.customer_org_group.id = ''
  465. setTimeout(() => {
  466. this.dataTransOpts.refresh.customer_org_group_detail.M++
  467. }, 20);
  468. }
  469. })
  470. .catch((err) => {
  471. if (err == "cancel") {
  472. console.log("已取消删除");
  473. // this.$message.info("已取消删除");
  474. }
  475. });
  476. },
  477. //计算总价
  478. computePrice() {
  479. if (!this.form.id) {
  480. this.$message.warning("尚未保存信息,不可执行此操作!");
  481. return;
  482. }
  483. let customerOrgGroupId = this.form.id;
  484. let customerOrgGroupAsbitems = []; //分组包含的套餐
  485. getapi(`/api/app/customerorggroupdetail/getcustomerorggroupdetailinasbitem?CustomerOrgGroupId=${customerOrgGroupId}
  486. `)
  487. .then((res) => {
  488. if (res.code != -1) {
  489. customerOrgGroupAsbitems = res.data;
  490. if (customerOrgGroupAsbitems.length < 1) {
  491. this.$message.warning("当前分组尚未设置组合项目,不可执行此操作!");
  492. } else {
  493. let body = {
  494. customerOrgGroupId,
  495. details: this.madeNewGroupAsbitems(
  496. customerOrgGroupAsbitems,
  497. this.form.price
  498. ),
  499. };
  500. console.log("body", body);
  501. return postapi(
  502. "/api/app/customerorggroupdetail/createcustomerorggroupdetailmany",
  503. body
  504. );
  505. }
  506. }
  507. })
  508. .then((res) => {
  509. if (res.code != -1) {
  510. //console.log("操作成功");
  511. //触发分组明细刷新
  512. this.form.id = "";
  513. //要做延时处理,否则不会触发监听
  514. setTimeout(() => {
  515. this.form.id = customerOrgGroupId;
  516. this.onSubmit("form");
  517. }, 100);
  518. }
  519. });
  520. },
  521. madeNewGroupAsbitems(oldGroupAsbitems, newTotal) {
  522. newTotal = Math.round(Number(newTotal) * 100) / 100;
  523. let newGroupAsbitems = [];
  524. let oldTotal = Number(0);
  525. oldGroupAsbitems.forEach((e) => {
  526. oldTotal += Number(e.asbitemMoney); //customerOrgGroupDetailMoney
  527. });
  528. oldTotal = Math.round(Number(oldTotal) * 100) / 100;
  529. let discount = 0;
  530. if (oldTotal != 0) discount = Math.round((newTotal * 10000) / oldTotal) / 100;
  531. oldTotal = Number(0);
  532. oldGroupAsbitems.forEach((e) => {
  533. e.customerOrgGroupDetailPrice = Math.round(e.price * discount) / 100;
  534. e.customerOrgGroupDetailMoney =
  535. Math.round(
  536. e.customerOrgGroupDetailPrice * e.customerOrgGroupDetailAmount * 100
  537. ) / 100;
  538. oldTotal += Number(e.customerOrgGroupDetailMoney);
  539. });
  540. oldTotal = Math.round(Number(oldTotal) * 100) / 100;
  541. //console.log('discount,oldTotal',discount,oldTotal)
  542. let didTotal = Math.round(Number(newTotal - oldTotal) * 100) / 100;
  543. if (didTotal != 0) {
  544. for (let i = 0; i < oldGroupAsbitems.length; i++) {
  545. if (oldGroupAsbitems[i].customerOrgGroupDetailAmount == 1) {
  546. oldGroupAsbitems[i].customerOrgGroupDetailPrice =
  547. Math.round(
  548. (Number(oldGroupAsbitems[i].customerOrgGroupDetailPrice) +
  549. Number(didTotal)) *
  550. 100
  551. ) / 100;
  552. break;
  553. }
  554. }
  555. }
  556. oldGroupAsbitems.forEach((e) => {
  557. newGroupAsbitems.push({
  558. customerOrgGroupId: e.customerOrgGroupId,
  559. asbitemId: e.asbitemId,
  560. price: e.customerOrgGroupDetailPrice,
  561. amount: e.customerOrgGroupDetailAmount,
  562. });
  563. });
  564. return newGroupAsbitems;
  565. },
  566. // 关闭 分组 新增/编辑
  567. close_dialogWinCustomerOrgGroupEdit() {
  568. let id = this.dataTransOpts.tableS.customer_org_group.id
  569. if (id) {
  570. // 点编辑 或 新增有提交
  571. getapi(`/api/app/customer-org-group/${id}`)
  572. .then(res => {
  573. if (res.code != -1) {
  574. let lfind = -1
  575. lfind = arrayExistObj(this.customerOrgGroups, 'id', id)
  576. if (lfind > -1) {
  577. objCopy(res.data, this.customerOrgGroups[lfind])
  578. } else {
  579. lfind = this.customerOrgGroups.length
  580. this.customerOrgGroups.push(res.data)
  581. }
  582. // 选中当前操作的列
  583. this.$refs["customerOrgGroups"].setCurrentRow(); //清除选择
  584. this.$refs["customerOrgGroups"].setCurrentRow(this.customerOrgGroups[lfind]);
  585. // 更新 customer_org_group_detail 参数
  586. this.curCustomerOrgGroup = deepCopy(res.data);
  587. this.curCustomerOrgGroup.isComplete = this.customerOrgRegister.isComplete;
  588. }
  589. })
  590. } else {
  591. // 点 新增 但未提交
  592. this.dataTransOpts.tableS.customer_org_group.id = this.curCustomerOrgGroup.id || ''
  593. }
  594. this.dataTransOpts.refresh.customer_org_group_detail.M++;
  595. },
  596. },
  597. };
  598. </script>
  599. <style scoped>
  600. @import "../../assets/css/global_button.css";
  601. @import "../../assets/css/global_dialog.css";
  602. @import "../../assets/css/global_table.css";
  603. @import "../../assets/css/global_form.css";
  604. @import "../../assets/css/global_input.css";
  605. @import "../../assets/css/global.css";
  606. .btnClass {
  607. width: 100px;
  608. margin-bottom: 5px;
  609. }
  610. </style>