jishuanqi.vue 9.9 KB

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