allocationNumber.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <div class="container-allocation-number-rai">
  3. <el-dialog title="派点" width="1300px" :visible.sync="allocationVisible" v-dialogDrag :close-on-click-modal="false" :modal-append-to-body="false" center @close="handleClose">
  4. <div class="top-content">
  5. <div>
  6. <h5>总点数:{{ TotalPointsContent }}</h5>
  7. <el-button style="margin-top: 20px" type="primary" size="mini" @click="averageaAllocation">平均分配</el-button>
  8. </div>
  9. <div>
  10. <p v-for="(item, index) in textualList" :key="item.text">{{ index + 1 }}{{ item.text }}</p>
  11. </div>
  12. </div>
  13. <div class="content-box">
  14. <div v-for="item in listArr" :key="item.ChartPermissionName">
  15. <div :class="['industry-ul', item.ChartPermissionName.includes('研选') && 'ul-yanxuan']">
  16. <span :class="['industry-name', item.ChartPermissionName.includes('研选') && 'name-yanxuan']">{{ item.ChartPermissionName }}</span>
  17. <template>
  18. <el-input :min="-100" :max="100" type="number" v-model="item.Proportion" size="small" @input="restrictInput(item)" style="width: 80px; margin: 0 5px 0 8px">
  19. <div class="per_cent_" slot="suffix">%</div>
  20. </el-input>
  21. <p style="width: 38px">{{ roundedResult(item) }}</p>
  22. </template>
  23. </div>
  24. <div v-for="study in item.List" :key="study.RealName" :class="['industry-ul', item.ChartPermissionName.includes('研选') && 'ul-yanxuan']">
  25. <span :class="['study-name', item.ChartPermissionName.includes('研选') && 'name-yanxuan']">{{ study.RealName }}</span>
  26. <template>
  27. <el-input :min="-100" :max="100" type="number" v-model="study.Proportion" size="small" style="width: 76px; margin: 0 5px 0 8px">
  28. <div class="per_cent_" slot="suffix">%</div>
  29. </el-input>
  30. <p style="width: 38px">{{ roundedResult(study) }}</p>
  31. </template>
  32. </div>
  33. <div class="all-item">
  34. <span> {{ allPerCentHandler(item) == 0 ? "" : `总占比:` }}</span>
  35. <span> {{ allPerCentHandler(item) == 0 ? "" : `${allPerCentHandler(item)}` }}</span>
  36. </div>
  37. </div>
  38. </div>
  39. <span slot="footer" class="dialog-footer">
  40. <el-button @click="handleClose">取 消</el-button>
  41. <el-button type="primary" @click="addAllocationHandler">确 定</el-button>
  42. </span>
  43. </el-dialog>
  44. </div>
  45. </template>
  46. <script>
  47. import { contractInterface } from "@/api/api.js";
  48. export default {
  49. name: "",
  50. components: {},
  51. props: {
  52. allocationVisible: {
  53. default: false,
  54. type: Boolean,
  55. },
  56. allocationForm: {
  57. type: Object,
  58. default: {},
  59. },
  60. },
  61. data() {
  62. return {
  63. listArr: [],
  64. allNum: 0,
  65. TotalPointsContent: "",
  66. isXClass: false,
  67. };
  68. },
  69. computed: {
  70. textualList() {
  71. let items = [
  72. {
  73. text: ")单行业套餐只能在对应行业内部分配研究员贡献百分比",
  74. },
  75. {
  76. text: ")多行业套餐先在行业间分配百分比(最低不低于平均值的一半),再分配到个人",
  77. },
  78. {
  79. text: ")允许总额20%以内的负分",
  80. },
  81. {
  82. text: ")转正后一个季度内可以提交和修改",
  83. },
  84. ];
  85. if (this.isXClass) {
  86. return items.filter((item, index) => index == 0 || index == 3);
  87. } else {
  88. return items;
  89. }
  90. },
  91. },
  92. watch: {
  93. allocationVisible: {
  94. handler(newVal) {
  95. newVal && this.getList();
  96. },
  97. immediate: true,
  98. },
  99. },
  100. created() {},
  101. mounted() {},
  102. methods: {
  103. // 取消弹框
  104. handleClose() {
  105. this.listArr = [];
  106. this.$emit("update:allocationForm", {});
  107. this.$emit("update:allocationVisible", false);
  108. },
  109. // 提交弹框
  110. async addAllocationHandler() {
  111. this.listArr.forEach((item) => {
  112. item.Money = Number(item.Money) || 0;
  113. item.Proportion = Number(item.Proportion) || 0;
  114. item.List.forEach((_) => {
  115. _.Money = Number(_.Money) || 0;
  116. _.Proportion = Number(_.Proportion) || 0;
  117. });
  118. });
  119. let arrList = this.listArr;
  120. const res = await contractInterface.getAllocationDetailUpdate({
  121. CompanyContractId: this.allocationForm.CompanyContractId,
  122. List: arrList,
  123. });
  124. if (res.Ret === 200) {
  125. this.$message.success("操作成功");
  126. this.$parent.getTableData();
  127. this.handleClose();
  128. }
  129. },
  130. // 处理百分比
  131. roundedResult(row) {
  132. let num = row.Proportion >= 0 ? (row.Proportion * 100) / 100 / 100 : row.Proportion / 100;
  133. row.Money = row.Proportion ? (this.allNum * num).toFixed(2) : "";
  134. return row.Money;
  135. },
  136. // 输入框的限制
  137. restrictInput(item) {
  138. if (item.Proportion > 100) return (item.Proportion = 100);
  139. if (item.Proportion < -100) return (item.Proportion = -100);
  140. },
  141. // 数量的总和
  142. allPerCentHandler(item) {
  143. let num = 0;
  144. item && item.List.forEach((key) => (num = num + +key.Proportion));
  145. return num.toFixed(2);
  146. },
  147. // 获取数据
  148. async getList() {
  149. const res = await contractInterface.getAllocationDetail({
  150. CompanyContractId: this.allocationForm.CompanyContractId,
  151. });
  152. if (res.Ret === 200) {
  153. this.allNum = res.Data.Money;
  154. this.listArr = res.Data.List;
  155. this.isXClass = res.Data.IsXClass;
  156. this.TotalPointsContent = res.Data.TotalPointsContent;
  157. }
  158. },
  159. // 平均分配
  160. averageaAllocation() {
  161. let num = (100 / this.listArr.length).toFixed(2);
  162. console.log(num);
  163. this.listArr.forEach((item) => {
  164. item.Proportion = num;
  165. let childrenNum = (num / item.List.length).toFixed(2);
  166. item.List.forEach((key) => {
  167. key.Proportion = childrenNum;
  168. });
  169. });
  170. },
  171. },
  172. };
  173. </script>
  174. <style lang="scss">
  175. .container-allocation-number-rai {
  176. overflow: hidden;
  177. .top-content {
  178. display: flex;
  179. justify-content: space-between;
  180. }
  181. .content-box {
  182. width: 100%;
  183. overflow: hidden;
  184. overflow-x: auto;
  185. display: flex;
  186. .industry-ul {
  187. display: flex;
  188. align-items: center;
  189. margin: 30px 0;
  190. width: 188px;
  191. color: #333;
  192. margin-right: 25px;
  193. .per_cent_ {
  194. line-height: 32px;
  195. }
  196. .industry-name {
  197. width: 58px;
  198. flex-shrink: 0;
  199. font-weight: 800;
  200. font-size: 16px;
  201. line-height: 22px;
  202. }
  203. .study-name {
  204. width: 58px;
  205. flex-shrink: 0;
  206. font-size: 14px;
  207. line-height: 22px;
  208. }
  209. p {
  210. color: #9999;
  211. font-size: 14px;
  212. }
  213. }
  214. }
  215. .all-item {
  216. display: flex;
  217. padding-right: 15px;
  218. align-items: center;
  219. // justify-content: center;
  220. color: #999;
  221. font-size: 14px;
  222. span {
  223. display: inline-block;
  224. width: 80px;
  225. }
  226. }
  227. .name-yanxuan {
  228. width: 70px !important;
  229. }
  230. .points-name {
  231. width: 80px !important;
  232. }
  233. .ul-yanxuan {
  234. width: 220px !important;
  235. }
  236. /* 取消[type='number']的input的上下箭头 */
  237. input::-webkit-inner-spin-button {
  238. -webkit-appearance: none !important;
  239. }
  240. input::-webkit-outer-spin-button {
  241. -webkit-appearance: none !important;
  242. }
  243. input[type="number"] {
  244. -moz-appearance: textfield;
  245. }
  246. }
  247. </style>