jishuanqi.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <div>
  3. <el-dropdown
  4. ref="dropdown"
  5. placement="bottom-start"
  6. trigger="click"
  7. @visible-change="handleMouseLeave"
  8. @close="handleClose"
  9. @mouseleave="handleMouseLeave"
  10. >
  11. <span class="el-dropdown-link">
  12. <el-input
  13. v-model="params.formula.noConditionFormula"
  14. @blur="handleMouseLeave"
  15. @change="handleMouseLeave"
  16. />
  17. </span>
  18. <template #dropdown>
  19. <div
  20. class="w-[500px] compute h-64 mt-1 ml-12 flex justify-evenly items-center"
  21. style="user-select: none"
  22. >
  23. <div class="w-1/3 h-60 pl-1 bg-white rounded-md">
  24. <div class="w-[100%] text-xs mt-2">
  25. <div><el-text type="info">:::变量</el-text></div>
  26. </div>
  27. <div v-for="item in rolesList.data" :key="item.id">
  28. <div
  29. :class="[
  30. 'cursor-pointer text-xs mt-1',
  31. { bgBack: bgColor === item.id }
  32. ]"
  33. @click="lookRoles(item)"
  34. >
  35. <el-text class="">{{ item.name }}</el-text>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="w-3/5 ml-2 h-60 flex flex-col">
  40. <div class="w-[100%] text-xs h-24 bg-white rounded-md">
  41. <div class="p-1"><el-text>得分 = </el-text></div>
  42. <!-- style="height: 95px" -->
  43. <el-input
  44. v-model="params.formula.noConditionFormula"
  45. :rows="3"
  46. disabled
  47. type="textarea"
  48. placeholder='示例:"完成值" / "目标值" * 100'
  49. />
  50. </div>
  51. <div class="w-[100%] h-32 mt-2 rounded-md flex flex-col">
  52. <div class="flex justify-between h-8">
  53. <div
  54. class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  55. @click="countNumber('1')"
  56. >
  57. 1
  58. </div>
  59. <div
  60. class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  61. @click="countNumber('2')"
  62. >
  63. 2
  64. </div>
  65. <div
  66. class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  67. @click="countNumber('3')"
  68. >
  69. 3
  70. </div>
  71. <div
  72. class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  73. @click="countNumber('+')"
  74. >
  75. +
  76. </div>
  77. <div
  78. class="h-full w-[50px] text-white bg-orange-400 mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  79. @click="remove"
  80. >
  81. x
  82. </div>
  83. </div>
  84. <div class="flex justify-between h-8 mt-1">
  85. <div
  86. class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  87. @click="countNumber('4')"
  88. >
  89. 4
  90. </div>
  91. <div
  92. class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  93. @click="countNumber('5')"
  94. >
  95. 5
  96. </div>
  97. <div
  98. class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  99. @click="countNumber('6')"
  100. >
  101. 6
  102. </div>
  103. <div
  104. class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  105. @click="countNumber('-')"
  106. >
  107. -
  108. </div>
  109. <div
  110. class="text-xs h-full w-[50px] text-white bg-orange-400 mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  111. @click="removeVoid"
  112. >
  113. 清空
  114. </div>
  115. </div>
  116. <div class="flex justify-between h-16 mt-1">
  117. <div>
  118. <div class="flex justify-between">
  119. <div
  120. class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  121. @click="countNumber('7')"
  122. >
  123. 7
  124. </div>
  125. <div
  126. class="h-full ml-1 w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  127. @click="countNumber('8')"
  128. >
  129. 8
  130. </div>
  131. <div
  132. class="h-full ml-2 w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  133. @click="countNumber('9')"
  134. >
  135. 9
  136. </div>
  137. <div
  138. class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  139. @click="countNumber('*')"
  140. >
  141. *
  142. </div>
  143. </div>
  144. <div class="flex mt-1 justify-between">
  145. <div
  146. class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  147. @click="countNumber('0')"
  148. >
  149. 0
  150. </div>
  151. <div
  152. class="h-full ml-1 w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  153. @click="countNumber('.')"
  154. >
  155. .
  156. </div>
  157. <div
  158. class="h-full ml-2 w-[50px] bg-white mx-1 flex justify-between items-center rounded-lg cursor-pointer"
  159. >
  160. <div
  161. class="w-1/2 h-full text-center border-r text-gray-100"
  162. @click="countNumber('(')"
  163. >
  164. <span class="text-black"> (</span>
  165. </div>
  166. <div
  167. class="w-1/2 h-full text-center"
  168. @click="countNumber(')')"
  169. >
  170. )
  171. </div>
  172. </div>
  173. <div
  174. class="h-full w-[50px] bg-white mx-1 flex justify-center items-center rounded-lg cursor-pointer"
  175. @click="countNumber('/')"
  176. >
  177. /
  178. </div>
  179. </div>
  180. </div>
  181. <div
  182. class="h-full mr-1 w-[50px] text-white flex justify-center items-center rounded-lg cursor-pointer areYouOK"
  183. @click="count"
  184. >
  185. 确认
  186. </div>
  187. </div>
  188. </div>
  189. </div>
  190. </div>
  191. </template>
  192. </el-dropdown>
  193. </div>
  194. </template>
  195. <script setup lang="ts">
  196. import { reactive, ref, onMounted } from "vue";
  197. const dropdown = ref();
  198. const $emit = defineEmits(["handClick", "clickIndex"]);
  199. const $props = defineProps({
  200. index: {
  201. type: Number
  202. },
  203. indexList: {
  204. type: Number
  205. },
  206. outerConditionValue: {
  207. type: String
  208. }
  209. });
  210. onMounted(() => {
  211. if ($props.outerConditionValue) {
  212. params.formula.noConditionFormula = $props.outerConditionValue;
  213. }
  214. });
  215. const bgColor = ref(null);
  216. const rolesList = reactive({
  217. data: [
  218. { name: "完成值 / 目标值", id: 1 },
  219. { name: "完成值 - 目标值", id: 2 },
  220. { name: "目标值 - 完成值", id: 3 },
  221. { name: "门槛值", id: 4 },
  222. { name: "目标值", id: 5 },
  223. { name: "挑战值", id: 6 },
  224. { name: "完成值", id: 7 },
  225. { name: "增幅", id: 8 },
  226. { name: "降幅", id: 9 }
  227. ],
  228. value: "",
  229. num: null
  230. });
  231. const params = reactive({
  232. formula: {
  233. noConditionFormula: ""
  234. }
  235. });
  236. const lookRoles = item => {
  237. bgColor.value = item.id;
  238. params.formula.noConditionFormula =
  239. params.formula.noConditionFormula + item.name;
  240. };
  241. // 字符拼接
  242. const countNumber = (item: string) => {
  243. params.formula.noConditionFormula = params.formula.noConditionFormula + item;
  244. };
  245. // 清空
  246. const removeVoid = () => {
  247. params.formula.noConditionFormula = "";
  248. };
  249. // 清除
  250. const remove = () => {
  251. if (params.formula.noConditionFormula.length > 0) {
  252. params.formula.noConditionFormula = params.formula.noConditionFormula.slice(
  253. 0,
  254. -1
  255. );
  256. }
  257. };
  258. // 确认
  259. const count = item => {
  260. $emit(
  261. "handClick",
  262. params.formula.noConditionFormula,
  263. $props.index,
  264. $props.indexList
  265. );
  266. };
  267. const handleClose = () => {
  268. console.log("关闭");
  269. };
  270. const handleMouseLeave = blo => {
  271. if (!blo) {
  272. $emit(
  273. "handClick",
  274. params.formula.noConditionFormula,
  275. $props.index,
  276. $props.indexList
  277. );
  278. }
  279. };
  280. defineExpose({
  281. params
  282. });
  283. </script>
  284. <style lang="scss" scoped>
  285. .compute {
  286. background-color: #f3f3f3;
  287. border-radius: 5px;
  288. }
  289. .text-color {
  290. color: #f3f3f3;
  291. }
  292. .areYouOK {
  293. background-color: #409eff;
  294. }
  295. .bgBack {
  296. background-color: #f3f3f3;
  297. }
  298. .text_border {
  299. display: flex;
  300. align-items: center;
  301. justify-content: center;
  302. width: 14px;
  303. height: 14px;
  304. // margin-top: 5px;
  305. margin-right: 5px;
  306. font-size: 12px;
  307. border: 1px solid gray;
  308. border-radius: 50%;
  309. }
  310. </style>