index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <!-- littlegreen - 企业效益监测评估 - 差对接查询接口 -->
  3. <div :class="className" :style="{ width: width, padding: '20px' }">
  4. <div class="select-container">
  5. <el-form
  6. style="
  7. display: grid;
  8. grid-template-columns: 1fr 1.3fr 1fr;
  9. align-items: center;
  10. grid-gap: 20px;
  11. "
  12. label-width="100px"
  13. >
  14. <el-form-item label="行业代码" style="margin-bottom: 0">
  15. <el-select
  16. v-model="form.code"
  17. style="width: 100%"
  18. filterable
  19. @change="codeChange"
  20. >
  21. <el-option
  22. v-for="item in selectedIndustryArray"
  23. :key="item.key"
  24. :label="item.value"
  25. :value="item.key"
  26. >
  27. </el-option>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="企业" style="margin-bottom: 0">
  31. <el-select
  32. v-model="form.enterpriseName"
  33. style="width: 100%"
  34. filterable
  35. clearable
  36. >
  37. <el-option
  38. v-for="item in selectedEnterpriseArray"
  39. :key="item.key"
  40. :label="item.value"
  41. :value="item.value"
  42. >
  43. </el-option>
  44. </el-select>
  45. </el-form-item>
  46. <el-form-item label="企业分类">
  47. <el-select v-model="form.typeNum" style="width: 100%" clearable>
  48. <el-option
  49. v-for="item in enterTypeList"
  50. :key="item.number"
  51. :value="item.number"
  52. :label="keyToChineseEtype(item.number)"
  53. >
  54. </el-option>
  55. </el-select>
  56. </el-form-item>
  57. <el-form-item label="年度" style="margin-bottom: 0">
  58. <el-select v-model="form.year" style="width: 100%">
  59. <el-option
  60. v-for="item in selectedYearArray"
  61. :key="item.key"
  62. :label="item.value"
  63. :value="item.key"
  64. >
  65. </el-option>
  66. </el-select>
  67. </el-form-item>
  68. <el-form-item label="季度" style="margin-bottom: 0">
  69. <el-select v-model="form.season" style="width: 100%" clearable>
  70. <el-option
  71. v-for="item in selectedSeasonArray"
  72. :key="item.key"
  73. :label="item.value"
  74. :value="item.key"
  75. >
  76. </el-option>
  77. </el-select>
  78. </el-form-item>
  79. <el-form-item label="分析方式" style="margin-bottom: 0">
  80. <el-select v-model="form.mode" style="width: 100%">
  81. <el-option
  82. v-for="item in selectedAnalyseArray"
  83. :key="item.key"
  84. :label="item.value"
  85. :value="item.key"
  86. >
  87. </el-option>
  88. </el-select>
  89. </el-form-item>
  90. <el-form-item style="margin-bottom: 0">
  91. <el-button
  92. type="primary"
  93. icon="el-icon-search"
  94. size="mini"
  95. @click="submit"
  96. >搜索</el-button
  97. ><el-button icon="el-icon-refresh" size="mini" @click="resetForm"
  98. >重置</el-button
  99. >
  100. </el-form-item>
  101. </el-form>
  102. </div>
  103. <el-table :data="tableData" border style="width: 100%; margin-top: 30px">
  104. <el-table-column
  105. prop="enterpriseName"
  106. label="企业名称"
  107. width="200"
  108. sortable
  109. align="center"
  110. ></el-table-column>
  111. <el-table-column
  112. prop="code"
  113. label="所属行业"
  114. width="100"
  115. align="center"
  116. ></el-table-column>
  117. <el-table-column
  118. align="center"
  119. prop="year"
  120. label="年度"
  121. width="100"
  122. ></el-table-column>
  123. <el-table-column
  124. prop="season"
  125. label="季度"
  126. width="100"
  127. align="center"
  128. sortable
  129. ></el-table-column>
  130. <el-table-column
  131. v-if="mode == 'trendAnalysis'"
  132. prop="trendAnalysis"
  133. label="趋势分析情况"
  134. width="300"
  135. ></el-table-column>
  136. <el-table-column
  137. v-if="mode == 'avgAnalysis'"
  138. prop="avgAnalysis"
  139. label="平均水平分析情况"
  140. width="350"
  141. ></el-table-column>
  142. <el-table-column
  143. prop="operationalEvaluate"
  144. label="企业运营评估结果参考"
  145. ></el-table-column>
  146. </el-table>
  147. <!-- <el-pagination
  148. @current-change="handlePageChange"
  149. :current-page="currentPage"
  150. :page-size="pageSize"
  151. :total="totalItems"
  152. hide-on-single-page
  153. background
  154. layout="total, prev, pager, next, jumper"
  155. style="float: right; margin-top: 20px; margin-bottom: 20px"
  156. >
  157. </el-pagination> -->
  158. <pagination
  159. v-show="total > 0"
  160. :total="total"
  161. :page.sync="form.pageNum"
  162. :limit.sync="form.pageSize"
  163. @pagination="getList"
  164. />
  165. <!-- <div ref="chart" :style="{ height: height, width: width }"></div> -->
  166. </div>
  167. </template>
  168. <script>
  169. import { listAllEnterprise } from "@/api/enterprise/enterprise";
  170. import { listAllIndustry } from "@/api/industry/industry";
  171. import { getIndexData } from "@/api/home";
  172. import { benefitList } from "@/api/benefit";
  173. import { listEtypeAll } from "@/api/etype/etype";
  174. export default {
  175. props: {
  176. className: {
  177. type: String,
  178. default: "chart",
  179. },
  180. width: {
  181. type: String,
  182. default: "100%",
  183. },
  184. height: {
  185. type: String,
  186. default: "400px",
  187. },
  188. },
  189. data() {
  190. return {
  191. selectedEnterpriseArray: [],
  192. EnterpriseArray: [],
  193. selectedYearArray: [],
  194. selectedIndustryArray: [],
  195. mode: "trendAnalysis",
  196. currentPage: 1,
  197. pageSize: 5,
  198. total: 0,
  199. form: {
  200. pageNum: 1,
  201. pageSize: 10,
  202. enterpriseName: null,
  203. year: null,
  204. code: null,
  205. season: "1",
  206. mode: "trendAnalysis",
  207. },
  208. selectedAnalyseArray: [
  209. {
  210. key: "trendAnalysis",
  211. value: "趋势分析",
  212. },
  213. {
  214. key: "avgAnalysis",
  215. value: "平均水平分析",
  216. },
  217. ],
  218. selectedSeasonArray: [
  219. {
  220. key: "1",
  221. value: "1季度",
  222. },
  223. {
  224. key: "2",
  225. value: "2季度",
  226. },
  227. {
  228. key: "3",
  229. value: "3季度",
  230. },
  231. {
  232. key: "4",
  233. value: "4季度",
  234. },
  235. ],
  236. tableData: [],
  237. enterTypeList: []
  238. };
  239. },
  240. computed: {
  241. // totalItems() {
  242. // return this.tableData.length;
  243. // },
  244. // paginatedData() {
  245. // const start = (this.currentPage - 1) * this.pageSize;
  246. // return this.tableData.slice(start, start + this.pageSize);
  247. // },
  248. },
  249. mounted() {
  250. this.init();
  251. },
  252. methods: {
  253. keyToChineseEtype(num) {
  254. const item = this.enterTypeList.find((element) => element.number === num);
  255. return item ? item.name : null;
  256. },
  257. handlePageChange(newPage) {
  258. this.currentPage = newPage;
  259. },
  260. sortByCode(arr) {
  261. return arr.sort((a, b) => {
  262. const numA = Number(a.code);
  263. const numB = Number(b.code);
  264. // 检查是否为有效数字
  265. const isANum = !isNaN(numA);
  266. const isBNum = !isNaN(numB);
  267. if (isANum && isBNum) {
  268. return numA - numB; // 都是数字,按数字升序排序
  269. } else if (isANum) {
  270. return -1; // a 是数字,放在前面
  271. } else if (isBNum) {
  272. return 1; // b 是数字,放在前面
  273. } else {
  274. return 0; // 都不是数字,保持原顺序
  275. }
  276. });
  277. },
  278. async init() {
  279. const that = this;
  280. // 获取所有的行业
  281. const loading = this.$loading({
  282. lock: true,
  283. text: "Loading",
  284. spinner: "el-icon-loading",
  285. background: "rgba(0, 0, 0, 0.7)",
  286. });
  287. await listAllIndustry()
  288. .then((res) => {
  289. if (res && res?.rows) {
  290. let arr = this.sortByCode(res.rows);
  291. that.selectedIndustryArray = arr.map((item) => {
  292. return {
  293. key: item.code,
  294. value: item.code + item.industryName,
  295. };
  296. });
  297. }
  298. })
  299. .catch((error) => {
  300. console.error("Error fetching data:", error);
  301. });
  302. // 获取所有的企业
  303. await listAllEnterprise()
  304. .then((res) => {
  305. if (res && res?.rows) {
  306. that.EnterpriseArray = res.rows.map((item) => {
  307. return {
  308. key: item.id,
  309. value: item.enterpriseName,
  310. code: item.code,
  311. };
  312. });
  313. }
  314. })
  315. .catch((error) => {
  316. console.error("Error fetching data:", error);
  317. });
  318. // 获取有的年份
  319. await getIndexData({
  320. year: 0,
  321. })
  322. .then((res) => {
  323. if (res && res?.rows) {
  324. that.selectedYearArray = res.rows[0].years.map((v) => {
  325. return {
  326. key: v,
  327. value: v,
  328. };
  329. });
  330. }
  331. })
  332. .catch((error) => {
  333. console.error("Error fetching data:", error);
  334. });
  335. await listEtypeAll().then((res) => {
  336. this.enterTypeList = res;
  337. })
  338. // 第一次的时候初始化from
  339. loading.close();
  340. this.resetForm();
  341. },
  342. submit() {
  343. this.form.pageNum = 1;
  344. this.getList();
  345. },
  346. getList() {
  347. const load = this.$loading({
  348. lock: true,
  349. text: "Loading",
  350. spinner: "el-icon-loading",
  351. background: "rgba(0, 0, 0, 0.7)",
  352. });
  353. benefitList(this.form)
  354. .then((res) => {
  355. load.close();
  356. if (res && res?.rows) {
  357. this.mode = this.form.mode;
  358. this.tableData = res.rows;
  359. this.total = res.total;
  360. }
  361. })
  362. .catch((error) => {
  363. load.close();
  364. console.error("Error fetching data:", error);
  365. });
  366. },
  367. resetForm() {
  368. // 过滤对应行业的的企业出来
  369. this.selectedEnterpriseArray = this.EnterpriseArray.filter(
  370. (item) => item.code == this.selectedIndustryArray[0].key
  371. );
  372. // 重置form表单
  373. this.form = {
  374. pageNum: 1,
  375. pageSize: 10,
  376. year: this.selectedYearArray[0].key,
  377. enterpriseName: null,
  378. code: this.selectedIndustryArray[0].key,
  379. season: null,
  380. mode: this.selectedAnalyseArray[0].key,
  381. };
  382. this.submit();
  383. },
  384. codeChange(e) {
  385. // 当选择的行业变化时,过滤对应行业的的企业出来
  386. this.selectedEnterpriseArray = this.EnterpriseArray.filter(
  387. (item) => item.code == e
  388. );
  389. this.form.enterpriseName = null;
  390. },
  391. },
  392. };
  393. </script>
  394. <style scoped>
  395. .select-container {
  396. margin: 10px 5px;
  397. font-size: 16px;
  398. }
  399. .select-container select {
  400. padding: 10px 20px;
  401. margin-right: 10px;
  402. border: 1px solid #121315;
  403. border-radius: 4px;
  404. background-color: white;
  405. color: #121315;
  406. font-size: 16px;
  407. cursor: pointer;
  408. outline: none;
  409. }
  410. .select-container select:hover {
  411. border-color: #1a7cc8;
  412. }
  413. .select-container select:focus {
  414. border-color: #121315;
  415. box-shadow: 0 0 0 2px rgba(64, 159, 255, 0.2);
  416. }
  417. </style>