importIndex.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <script setup lang="ts">
  2. import { ref, reactive, computed } from "vue";
  3. import { ElMessageBox, ElMessage, ElTable } from "element-plus";
  4. import { Search } from "@element-plus/icons-vue";
  5. import { getQuotaPageList } from "@/api/indexDefine";
  6. import { postAddRelationList } from "@/api/dimension";
  7. import { getSelectDictListtApi, select } from "@/api/select";
  8. import { getStateData, getStateType } from "@/config/tag";
  9. const dialogVisibleAdd = ref(false);
  10. const $emit = defineEmits(["handClickInit"]);
  11. const indexParams = reactive({
  12. params: {
  13. pageNumber: 1,
  14. pageSize: 5,
  15. categoryName: "",
  16. param: ""
  17. },
  18. tableData: [],
  19. total: 0,
  20. tableIndex: [],
  21. Relation: {
  22. dimId: "",
  23. indId: "",
  24. tpId: "",
  25. indName: "",
  26. scoreRule: "",
  27. targetValue: "",
  28. finalValue: "",
  29. challengeValue: "",
  30. startValue: "",
  31. datasoure: "",
  32. weight: "",
  33. scoreValue: ""
  34. },
  35. parentList: {}
  36. });
  37. const handleClose = () => {
  38. dialogVisibleAdd.value = !dialogVisibleAdd.value;
  39. // ElMessageBox.confirm("确认关闭弹窗吗?")
  40. // .then(() => {
  41. // ElMessage({
  42. // message: "已关闭"
  43. // });
  44. // })
  45. // .catch(() => {
  46. // // catch error
  47. // });
  48. };
  49. // 添加部门保存
  50. const saveDepartment = async () => {
  51. const { code, msg, data } = await postAddRelationList(indexParams.tableIndex);
  52. if (code === 200) {
  53. if (data.successList.length > 0) {
  54. $emit("handClickInit");
  55. ElMessage({
  56. message: "导入成功",
  57. type: "success"
  58. });
  59. }
  60. if (data.failList.length > 0) {
  61. data.failList.map(it => {
  62. ElMessage({
  63. message: `指标${it.indName}重复导入`,
  64. type: "error"
  65. });
  66. });
  67. }
  68. } else {
  69. ElMessage.error(msg);
  70. }
  71. // indexParams.tableIndex.forEach(async item => {
  72. // indexParams.Relation.indId = item.id;
  73. // indexParams.Relation.indName = item.name;
  74. // if (code === 200) {
  75. // if (data.successList.length > 0) {
  76. // $emit("handClickInit");
  77. // console.log("11111", indexParams.parentList);
  78. // ElMessage({
  79. // message: "导入成功",
  80. // type: "success"
  81. // });
  82. // }
  83. // if (data.failList.length > 0) {
  84. // console.log("11111", data.failList);
  85. // ElMessage({
  86. // message: `指标${data.failList[0].indName}重复导入`,
  87. // type: "error"
  88. // });
  89. // }
  90. // } else {
  91. // ElMessage.error(msg);
  92. // }
  93. // });
  94. dialogVisibleAdd.value = false;
  95. // ElMessageBox.confirm("不保存,更新的信息将会丢失", "需要保存吗?", {
  96. // type: "warning"
  97. // })
  98. // .then(async () => {
  99. // })
  100. // .catch(() => {
  101. // // catch error
  102. // });
  103. };
  104. const open = row => {
  105. console.log("item", row);
  106. Object.assign(indexParams.parentList, row);
  107. indexParams.Relation.dimId = row.id;
  108. indexParams.Relation.tpId = row.tpId;
  109. dialogVisibleAdd.value = true;
  110. getQuotaPageListApi();
  111. getSelectDictListtApi();
  112. };
  113. // 选中
  114. const selectedNums = ref(0);
  115. const handleSelectionChange = selectedRows => {
  116. // this.selectedRows = selectedRows;
  117. indexParams.tableIndex = [];
  118. selectedNums.value = selectedRows.length;
  119. selectedRows.forEach((item, index) => {
  120. indexParams.tableIndex.push({
  121. dimId: indexParams.Relation.dimId,
  122. indId: item.id,
  123. tpId: indexParams.Relation.tpId,
  124. indName: item.name,
  125. scoreRule: "",
  126. targetValue: "",
  127. finalValue: "",
  128. challengeValue: "",
  129. startValue: "",
  130. datasoure: item.datasoure,
  131. weight: "",
  132. scoreValue: "",
  133. order: indexParams.parentList.tableData.length + index,
  134. importStatus: true
  135. });
  136. });
  137. // indexParams.tableIndex = selectedRows;
  138. console.log("选中的行:", indexParams.tableIndex);
  139. };
  140. const getQuotaPageListApi = async () => {
  141. const { code, data, msg } = await getQuotaPageList(indexParams.params);
  142. if (code == 200) {
  143. indexParams.tableData = data.records;
  144. indexParams.total = data.totalRow;
  145. } else {
  146. ElMessage.error(msg);
  147. }
  148. };
  149. const handleSizeChange = (val: number) => {
  150. // console.log("a4val1111", val);
  151. indexParams.params.pageSize = val;
  152. getQuotaPageListApi();
  153. };
  154. const handleCurrentChange = (val: number) => {
  155. // console.log("a4va2222222", val);
  156. indexParams.params.pageNumber = val;
  157. getQuotaPageListApi();
  158. };
  159. defineExpose({
  160. open
  161. });
  162. </script>
  163. <template>
  164. <div>
  165. <el-dialog v-model="dialogVisibleAdd" title="导入指标" width="744">
  166. <div class="w-full flex justify-between items-center">
  167. <div>
  168. <el-text>指标分类</el-text>
  169. <el-select
  170. v-model="indexParams.params.categoryName"
  171. clearable
  172. filterable
  173. placeholder="请选择"
  174. style="width: 200px"
  175. class="ml-3"
  176. @change="getQuotaPageListApi"
  177. >
  178. <el-option
  179. v-for="(item, index) in select"
  180. :key="index"
  181. :label="item.dictValue"
  182. :value="item.dictValue"
  183. />
  184. </el-select>
  185. </div>
  186. <div>
  187. <el-input
  188. v-model="indexParams.params.param"
  189. :prefix-icon="Search"
  190. placeholder="请输入"
  191. @change="getQuotaPageListApi"
  192. />
  193. </div>
  194. </div>
  195. <el-table
  196. :data="indexParams.tableData"
  197. style="width: 100%"
  198. @selection-change="handleSelectionChange"
  199. >
  200. <el-table-column type="selection" width="55" />
  201. <el-table-column label="指标名称">
  202. <template #default="scope">{{ scope.row.name }}</template>
  203. </el-table-column>
  204. <el-table-column prop="categoryName" label="指标分类" width="100" />
  205. <el-table-column
  206. property="statue"
  207. label="状态"
  208. width="100"
  209. show-overflow-tooltip
  210. >
  211. <template #default="scope">
  212. <el-tag :type="getStateType(scope.row.statue)">
  213. {{ getStateData(scope.row.statue) }}
  214. </el-tag>
  215. </template>
  216. </el-table-column>
  217. <el-table-column property="source" label="数据来源" width="120" />
  218. </el-table>
  219. <div class="w-full flex justify-between items-center">
  220. <div class="ml-10 mt-5">
  221. <el-text>共{{ indexParams.total }}项数据</el-text>
  222. </div>
  223. <div class="mr-10">
  224. <el-pagination
  225. v-model:current-page="indexParams.params.pageNumber"
  226. v-model:page-size="indexParams.params.pageSize"
  227. size="small"
  228. background
  229. layout="prev, pager, next"
  230. :total="indexParams.total"
  231. class="mt-4"
  232. @size-change="handleSizeChange"
  233. @current-change="handleCurrentChange"
  234. />
  235. </div>
  236. </div>
  237. <template #footer>
  238. <div class="dialog-footer w-full flex justify-between mt-4">
  239. <div>
  240. <el-text>已选择</el-text>
  241. <el-text type="primary">
  242. {{ selectedNums }}
  243. </el-text>
  244. <el-text>项</el-text>
  245. </div>
  246. <div>
  247. <el-button @click="handleClose">取消</el-button>
  248. <el-button type="primary" @click="saveDepartment"> 确认 </el-button>
  249. </div>
  250. </div>
  251. </template>
  252. </el-dialog>
  253. </div>
  254. </template>