scoringRulesNewDetailPage.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <div class="rulesNewDetail">
  3. <el-dialog title="考评得分规则详情" v-model="editEvaluaVisible" width='50vw' :close-on-click-modal="false">
  4. <div class="periodFrom">
  5. <div class="detailTable">
  6. <el-table
  7. size="mini"
  8. :highlight-current-row="true"
  9. :stripe="false"
  10. :border="false"
  11. max-height="240"
  12. ref="multipleTable"
  13. :data="indicItemoptions"
  14. @select-all="onSelectAll"
  15. @selection-change="selectItem"
  16. @row-click="onSelectOp"
  17. >
  18. <el-table-column type="selection" width="55" align="center" />
  19. <el-table-column label="子指标名称" prop="childName" />
  20. <el-table-column label="子指标编号" prop="childCode" />
  21. </el-table>
  22. </div>
  23. <p style="margin-bottom: 5px;color: red">注:请勾选指标项进行公式配置</p>
  24. <div class="fromCenter">
  25. <el-tabs type="border-card">
  26. <el-tab-pane label="指标项">
  27. <el-table
  28. size="mini"
  29. :highlight-current-row="true"
  30. :stripe="false"
  31. :border="false"
  32. ref="optionMul"
  33. :key="multipleSelectionObj?.childCode"
  34. height="240"
  35. @select-all="optionMulAll"
  36. @selection-change="optionMulItem"
  37. @row-dblclick="rowDbclick"
  38. :data="multipleSelectionObj?multipleSelectionObj.list:[]"
  39. >
  40. <el-table-column type="selection" width="55" align="center" />
  41. <el-table-column label="指标项名称" prop="optionName" />
  42. <el-table-column label="指标项编码" prop="optionCode" />
  43. <el-table-column label="计算公式" prop="formula" />
  44. </el-table>
  45. </el-tab-pane>
  46. <el-tab-pane label="函数">
  47. <el-table
  48. size="mini"
  49. fit
  50. :show-header="false"
  51. :highlight-current-row="true"
  52. :stripe="false"
  53. :border="false"
  54. height="240"
  55. @row-dblclick="tabFuncRowClickHandle"
  56. :data="funcMsg"
  57. >
  58. <el-table-column min-width="40%">
  59. <template #default="scope">
  60. <el-popover trigger="hover" placement="bottom">
  61. <p>描述:{{ scope.row.formulaName }}</p>
  62. <!-- <p>参数:{{ scope.row.param }}</p> -->
  63. <template #reference>
  64. <span size="medium" transition="fade-in-linear">{{
  65. scope.row.formulaName
  66. }}</span>
  67. </template>
  68. </el-popover>
  69. </template>
  70. </el-table-column>
  71. <el-table-column min-width="60%">
  72. <template #default="scope">
  73. <el-popover trigger="hover" placement="bottom">
  74. <p>描述:{{ scope.row.description }}</p>
  75. <!-- <p>参数:{{ scope.row.param }}</p> -->
  76. <template #reference>
  77. <span size="medium" transition="fade-in-linear">{{
  78. scope.row.description
  79. }}</span>
  80. </template>
  81. </el-popover>
  82. </template>
  83. </el-table-column>
  84. </el-table>
  85. </el-tab-pane>
  86. <el-tab-pane label="运算符">
  87. <el-button-group>
  88. <el-button
  89. v-for="item in operator"
  90. :key="item"
  91. plain
  92. @click="scorRuleSplit(item, 'operator')"
  93. style="width: 60px; margin: 7px 12px; height: 40px; border: 1px solid #409EFF;"
  94. >
  95. {{ item }}
  96. </el-button>
  97. </el-button-group>
  98. </el-tab-pane>
  99. </el-tabs>
  100. </div>
  101. <div>
  102. <div style="display:flex">
  103. <el-checkbox style="margin-right: 10px" v-model="isrepresentation"/>
  104. <el-tag style="margin-bottom: 5px">公式</el-tag>
  105. </div>
  106. <el-input
  107. type="textarea"
  108. rows="5"
  109. v-model="representation"
  110. @blur="representationBlur"
  111. id="representation"
  112. />
  113. </div>
  114. </div>
  115. <template #footer>
  116. <span class="dialog-footer">
  117. <el-button @click="editEvaluaVisible = false">取 消</el-button>
  118. <el-button type="primary" @click="saveAndEditIndicatorData()">确 定</el-button>
  119. </span>
  120. </template>
  121. </el-dialog>
  122. </div>
  123. </template>
  124. <script>
  125. import {apiGetIndidicselectById, apiGetIndicatordicsaveList, apiGetfunctionList} from '../../api/api'
  126. export default {
  127. data() {
  128. return {
  129. editEvaluaVisible: false,
  130. indicItemoptions: [],
  131. indicItem: '',
  132. isrepresentation: true,
  133. isrange: false,
  134. funcMsg: [],
  135. operator: [],
  136. representation: '',
  137. page:{
  138. pagesize: 12,
  139. currentPage: 1,
  140. total: 0
  141. },
  142. rowevalradio: {},
  143. multipleSelection: [],
  144. multipleSelectionObj: {},
  145. rulesNewDetailData: [],
  146. optionMulItemObj: {}
  147. }
  148. },
  149. created() {
  150. this.operator = ["+", "-", "*", "/", "(", ")", ">", ">=", "<", "<=", "==", "!=",
  151. "&&", "||", "!", "%", "true", "false", ".", ]
  152. },
  153. methods: {
  154. init(row) {
  155. this.editEvaluaVisible = true
  156. this.indicItemoptions = []
  157. this.multipleSelection = []
  158. this.multipleSelectionObj = {}
  159. this.rowevalradio = row
  160. this.getIndidicselectById(row)
  161. this.getFunData()
  162. },
  163. getIndidicselectById(row) {
  164. let that = this
  165. let params = {
  166. id: row.id
  167. }
  168. apiGetIndidicselectById(params).then(datas =>{
  169. if (datas && datas.data) {
  170. that.indicItemoptions = datas.data.dtoList
  171. that.multipleSelection = [datas.data.dtoList[0]]
  172. that.multipleSelectionObj = datas.data.dtoList[0]
  173. that.$nextTick(() =>{
  174. that.$refs.multipleTable.toggleRowSelection(that.multipleSelectionObj, true)
  175. })
  176. }
  177. })
  178. },
  179. representationBlur(val) {
  180. this.optionMulItemObj.formula = document.getElementById("representation").value
  181. },
  182. // 函数查询
  183. getFunData() {
  184. let that = this
  185. apiGetfunctionList().then(datas =>{
  186. if (datas && datas.data) {
  187. that.funcMsg = datas.data
  188. }
  189. })
  190. },
  191. onSelectAll() {
  192. this.$refs.multipleTable.clearSelection();
  193. },
  194. selectItem(rows) {
  195. document.getElementById("representation").value = ''
  196. this.optionMulItemObj = {}
  197. if (rows.length > 1) {
  198. const newRows = rows.filter((it, index) => {
  199. if (index == rows.length - 1) {
  200. this.$refs.multipleTable.toggleRowSelection(it, true);
  201. return true;
  202. } else {
  203. this.$refs.multipleTable.toggleRowSelection(it, false);
  204. return false;
  205. }
  206. });
  207. this.multipleSelection = newRows;
  208. this.multipleSelectionObj = newRows[0]
  209. } else {
  210. this.multipleSelection = rows;
  211. this.multipleSelectionObj = {}
  212. this.multipleSelectionObj = rows[0]
  213. }
  214. },
  215. onSelectOp(row) {
  216. this.$refs.multipleTable.clearSelection();
  217. this.$refs.multipleTable.toggleRowSelection(row, true);
  218. this.multipleSelection = [];
  219. this.multipleSelectionObj = {}
  220. this.multipleSelectionObj = row;
  221. this.multipleSelection.push(row);
  222. },
  223. tabFuncRowClickHandle(row) {
  224. let elInput = null
  225. if (this.isrepresentation) {
  226. elInput = document.getElementById("representation");
  227. } else {
  228. elInput = document.getElementById("range");
  229. }
  230. let startPos = elInput.selectionStart; //第0个字符到选中的字符
  231. let endPos = elInput.selectionEnd; //选中字符到末尾字符
  232. if (startPos === undefined || endPos === undefined) return;
  233. let txt = elInput.value;
  234. let func = row.formulaExpresion
  235. // 将插值添加到选中光标位置
  236. let result = txt.substring(0, startPos) + func + txt.substring(endPos);
  237. elInput.value = result;
  238. elInput.focus();
  239. },
  240. rowDbclick(row) {
  241. this.scorRuleSplit(row.optionCode);
  242. },
  243. scorRuleSplit(val, type) {
  244. let elInput = null
  245. if (this.isrepresentation) {
  246. elInput = document.getElementById("representation");
  247. } else {
  248. elInput = document.getElementById("range");
  249. }
  250. let startPos = elInput.selectionStart;
  251. let endPos = elInput.selectionEnd;
  252. if (startPos === undefined || endPos === undefined) return;
  253. let txt = elInput.value;
  254. let txtSplit = ''
  255. if (type === 'operator') {
  256. txtSplit = val
  257. } else {
  258. txtSplit = '['+val+']'
  259. }
  260. let result = txt.substring(0, startPos) + txtSplit + txt.substring(endPos);
  261. elInput.value = result;
  262. elInput.focus();
  263. elInput.selectionStart = startPos + txtSplit.length;
  264. elInput.selectionEnd = startPos + txtSplit.length;
  265. },
  266. optionMulAll() {
  267. this.$refs.optionMul.clearSelection();
  268. },
  269. optionMulItem(row) {
  270. if (row.length > 1) {
  271. const newRows = row.filter((it, index) => {
  272. if (index == row.length - 1) {
  273. this.$refs.optionMul.toggleRowSelection(it, true);
  274. return true;
  275. } else {
  276. this.$refs.optionMul.toggleRowSelection(it, false);
  277. return false;
  278. }
  279. })
  280. // this.representation = newRows[0].formula
  281. document.getElementById("representation").value = newRows[0].formula
  282. this.optionMulItemObj = newRows[0]
  283. } else {
  284. this.optionMulItemObj = row[0]
  285. // this.representation = this.optionMulItemObj.formula
  286. document.getElementById("representation").value = row[0].formula
  287. }
  288. },
  289. //新增/修改指标数据
  290. saveAndEditIndicatorData() {
  291. let that = this
  292. that.indicItemoptions.forEach(item =>{
  293. item.list.forEach(it =>{
  294. it.formula = it.formula !== '' ? encodeURI(it.formula) : ''
  295. })
  296. })
  297. let params = that.indicItemoptions
  298. apiGetIndicatordicsaveList(params).then(datas =>{
  299. if (datas) {
  300. that.$message({
  301. message: '指标项修改成功',
  302. type: 'success'
  303. });
  304. that.editEvaluaVisible = false
  305. }
  306. })
  307. },
  308. }
  309. }
  310. </script>
  311. <style lang="less">
  312. .rulesNewDetail{
  313. .el-overlay{
  314. .el-dialog{
  315. margin-top: 5vh;
  316. .el-dialog__body{
  317. padding: 20px !important;
  318. }
  319. .periodFrom{
  320. .detailTable{
  321. margin-bottom: 10px;
  322. }
  323. .fromCenter{
  324. margin-right: 20px;
  325. margin-bottom: 10px;
  326. .el-tabs{
  327. height: 100%;
  328. }
  329. }
  330. }
  331. }
  332. .el-dialog__footer{
  333. .dialog-footer{
  334. display: flex;
  335. justify-content: center;
  336. .el-button{
  337. width: 180px !important;
  338. height: 40px !important;
  339. }
  340. }
  341. }
  342. }
  343. }
  344. </style>