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.

289 lines
8.8 KiB

2 years ago
3 weeks ago
2 years ago
2 years ago
3 weeks ago
2 years ago
2 years ago
3 weeks ago
2 years ago
3 weeks ago
3 weeks ago
2 years ago
2 years ago
2 years ago
3 weeks ago
2 years ago
2 years ago
2 years ago
3 weeks ago
2 years ago
3 weeks ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 weeks ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 weeks ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div>
  3. <el-form :model="form" label-width="180px" :rules="rules" ref="form">
  4. <el-row>
  5. <el-col :span="24">
  6. <el-form-item prop="commonTableTypeId" label="分类">
  7. <el-select v-model="form.commonTableTypeId" placeholder="请选择" size="small" disabled>
  8. <el-option v-for="item in commonTableTypes" :key="item.id" :label="item.displayName" :value="item.id">
  9. </el-option>
  10. </el-select>
  11. </el-form-item>
  12. </el-col>
  13. </el-row>
  14. <el-row>
  15. <el-col :span="24">
  16. <el-form-item prop="displayName" label="体检系统编码">
  17. <el-input v-model="form.displayName" size="small" />
  18. </el-form-item>
  19. </el-col>
  20. </el-row>
  21. <el-row>
  22. <el-col :span="24">
  23. <el-form-item prop="simpleCode" label="体检系统名称">
  24. <el-input v-model="form.simpleCode" size="small" />
  25. </el-form-item>
  26. </el-col>
  27. </el-row>
  28. <el-row v-for="col in Object.keys(commonTableCols)">
  29. <el-col :span="24">
  30. <el-form-item :prop="col" :label="commonTableCols[col]">
  31. <el-input v-model="form[col]" size="small" />
  32. </el-form-item>
  33. </el-col>
  34. </el-row>
  35. </el-form>
  36. <div style="display: flex;margin-top: 15px;justify-content:space-between;">
  37. <div></div>
  38. <div style="display: flex;">
  39. <el-button class="commonbutton" @click="dialogWin.CommonTableEdit = false">关闭</el-button>
  40. <!--
  41. <el-button type="success" @click="computePrice">同比折算组合项目价格</el-button>
  42. -->
  43. <el-button class="commonbutton" type="primary" @click="onSubmit('form')">确定</el-button>
  44. </div>
  45. </div>
  46. </div>
  47. </template>
  48. <script>
  49. import moment from "moment";
  50. import { getapi, postapi, putapi, deletapi } from "@/api/api";
  51. import { mapState } from "vuex";
  52. import {
  53. dddw,
  54. deepCopy,
  55. objCopy,
  56. arrayExistObj,
  57. } from "../../utlis/proFunc";
  58. export default {
  59. components: {
  60. },
  61. props: ["params","commonTableCols"],
  62. data() {
  63. return {
  64. form: {
  65. id: "",
  66. commonTableTypeId: null, //所属体检次数
  67. displayName: "",
  68. simpleCode:"",
  69. dataCode: "",
  70. dataCode2: "",
  71. dataCode3: "",
  72. dataCode4: "",
  73. dataCode5: "",
  74. dataCode6: "",
  75. dataCode7: "",
  76. dataCode8: "",
  77. dataCode9: ""
  78. },
  79. editType: 'insert',
  80. commonTableTypes: [], //
  81. formInit: {}, //表单初始值
  82. rules: {
  83. commonTableTypeId: [{ required: true, message: "请填写分类名称", trigger: "blur" }],
  84. dataCode: [{ required: true, message: "请填写dataCode", trigger: "blur" }],
  85. displayName: [{ required: true, message: "请填写分组名称", trigger: "blur" }],
  86. },
  87. };
  88. },
  89. computed: {
  90. ...mapState(["dict", "dialogWin", "dataTransOpts"]),
  91. },
  92. created() {
  93. this.form.id = this.params.id
  94. this.form.commonTableTypeId = this.params.commonTableTypeId
  95. },
  96. mounted() {
  97. // 获取初始数据(单位、适用性别)
  98. this.dictInit();
  99. this.getFormData(this.params.id);
  100. },
  101. methods: {
  102. moment, dddw, deepCopy,
  103. // 获取初始数据
  104. dictInit() {
  105. //获取适用性别
  106. postapi("/api/app/CommonTableType/GetList").then((res) => {
  107. if (res.code != -1) {
  108. this.commonTableTypes = res.data;
  109. }
  110. });
  111. },
  112. // 生成表单数据
  113. getFormData(id) {
  114. this.$refs['form'].resetFields();
  115. if (id) {
  116. postapi('/api/app/CommonTable/Get', { commonTableId: id })
  117. .then(res => {
  118. if (res.code != -1) {
  119. this.form = deepCopy(res.data)
  120. }
  121. })
  122. this.editType = 'update'
  123. } else {
  124. // console.log('this.formInit', this.formInit)
  125. // this.form = this.$options.data().form
  126. this.form = Object.assign({}, this.formInit, { commonTableTypeId: this.params.commonTableTypeId })
  127. this.editType = 'insert'
  128. }
  129. },
  130. onSubmit(formName) {
  131. this.$refs[formName].validate((valid, fields) => {
  132. if (!valid) {
  133. this.$message.warning(fields[Object.keys(fields)[0]][0].message);
  134. return false;
  135. }
  136. let url = '/api/app/CommonTable/Create'
  137. let body = deepCopy(this.form);
  138. body.commonTableId = body.id
  139. if (this.editType == 'update') {
  140. url = '/api/app/CommonTable/Update'
  141. }
  142. //新增 编辑
  143. postapi(url, body)
  144. .then(res => {
  145. if (res.code != -1) {
  146. console.log("操作成功!");
  147. if(this.editType == 'insert') this.dataTransOpts.tableS.common_table.id = res.data.id
  148. this.dialogWin.CommonTableEdit = false;
  149. }
  150. });
  151. });
  152. },
  153. //
  154. computePrice() {
  155. if (!this.form.id) {
  156. this.$message.warning("尚未保存信息,不可执行此操作!");
  157. return;
  158. }
  159. let customerOrgGroupId = this.form.id;
  160. let customerOrgGroupAsbitems = []; //分组包含的套餐
  161. getapi(`/api/app/customerorggroupdetail/getcustomerorggroupdetailinasbitem?CustomerOrgGroupId=${customerOrgGroupId}`)
  162. .then((res) => {
  163. if (res.code != -1) {
  164. customerOrgGroupAsbitems = res.data;
  165. if (customerOrgGroupAsbitems.length < 1) {
  166. this.$message.warning("当前分组尚未设置组合项目,不可执行此操作!");
  167. } else {
  168. let body = {
  169. customerOrgGroupId,
  170. details: this.madeNewGroupAsbitems(
  171. customerOrgGroupAsbitems,
  172. this.form.price
  173. ),
  174. };
  175. console.log("body", body);
  176. return postapi("/api/app/customerorggroupdetail/createcustomerorggroupdetailmany", body);
  177. }
  178. }
  179. })
  180. .then((res) => {
  181. if (res.code != -1) {
  182. //console.log("操作成功");
  183. //触发分组明细刷新
  184. this.form.id = "";
  185. //要做延时处理,否则不会触发监听
  186. setTimeout(() => {
  187. this.form.id = customerOrgGroupId;
  188. this.onSubmit("form");
  189. }, 100);
  190. }
  191. });
  192. },
  193. madeNewGroupAsbitems(oldGroupAsbitems, newTotal) {
  194. newTotal = Math.round(Number(newTotal) * 100) / 100;
  195. let newGroupAsbitems = [];
  196. let oldTotal = Number(0);
  197. oldGroupAsbitems.forEach((e) => {
  198. oldTotal += Number(e.asbitemMoney); //customerOrgGroupDetailMoney
  199. });
  200. oldTotal = Math.round(Number(oldTotal) * 100) / 100;
  201. let discount = 0;
  202. if (oldTotal != 0) discount = Math.round((newTotal * 10000) / oldTotal) / 100;
  203. oldTotal = Number(0);
  204. oldGroupAsbitems.forEach((e) => {
  205. e.customerOrgGroupDetailPrice = Math.round(e.price * discount) / 100;
  206. e.customerOrgGroupDetailMoney =
  207. Math.round(
  208. e.customerOrgGroupDetailPrice * e.customerOrgGroupDetailAmount * 100
  209. ) / 100;
  210. oldTotal += Number(e.customerOrgGroupDetailMoney);
  211. });
  212. oldTotal = Math.round(Number(oldTotal) * 100) / 100;
  213. //console.log('discount,oldTotal',discount,oldTotal)
  214. let didTotal = Math.round(Number(newTotal - oldTotal) * 100) / 100;
  215. if (didTotal != 0) {
  216. for (let i = 0; i < oldGroupAsbitems.length; i++) {
  217. if (oldGroupAsbitems[i].customerOrgGroupDetailAmount == 1) {
  218. oldGroupAsbitems[i].customerOrgGroupDetailPrice =
  219. Math.round(
  220. (Number(oldGroupAsbitems[i].customerOrgGroupDetailPrice) +
  221. Number(didTotal)) *
  222. 100
  223. ) / 100;
  224. break;
  225. }
  226. }
  227. }
  228. oldGroupAsbitems.forEach((e) => {
  229. newGroupAsbitems.push({
  230. customerOrgGroupId: e.customerOrgGroupId,
  231. asbitemId: e.asbitemId,
  232. price: e.customerOrgGroupDetailPrice,
  233. amount: e.customerOrgGroupDetailAmount,
  234. });
  235. });
  236. return newGroupAsbitems;
  237. },
  238. },
  239. //监听事件
  240. watch: {
  241. // 体检分组ID未切换换时 也可以强制刷新数据
  242. "dataTransOpts.refresh.common_table.S": {
  243. // immediate: true,
  244. handler(newVal, oldVal) {
  245. console.log(`watch 体检分组 newVal:${newVal} oldVal:${oldVal} common_table.id: ${this.params.id}`);
  246. if (newVal != oldVal) this.getFormData(this.params.id);
  247. }
  248. },
  249. },
  250. };
  251. </script>
  252. <style scoped>
  253. @import "../../assets/css/global_button.css";
  254. @import "../../assets/css/global_dialog.css";
  255. @import "../../assets/css/global_table.css";
  256. @import "../../assets/css/global_form.css";
  257. @import "../../assets/css/global_input.css";
  258. @import "../../assets/css/global.css";
  259. .btnClass {
  260. width: 100px;
  261. margin-bottom: 5px;
  262. }
  263. </style>