index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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="年度" style="margin-bottom: 0">
  47. <el-select v-model="form.year" style="width: 100%">
  48. <el-option
  49. v-for="item in selectedYearArray"
  50. :key="item.key"
  51. :label="item.value"
  52. :value="item.key"
  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.season" style="width: 100%" clearable>
  59. <el-option
  60. v-for="item in selectedSeasonArray"
  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.mode" style="width: 100%">
  70. <el-option
  71. v-for="item in selectedAnalyseArray"
  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 style="margin-bottom: 0">
  80. <el-button
  81. type="primary"
  82. icon="el-icon-search"
  83. size="mini"
  84. @click="submit"
  85. >搜索</el-button
  86. ><el-button icon="el-icon-refresh" size="mini" @click="resetForm"
  87. >重置</el-button
  88. >
  89. </el-form-item>
  90. </el-form>
  91. </div>
  92. <el-table
  93. :data="paginatedData"
  94. border
  95. style="width: 100%; margin-top: 30px"
  96. >
  97. <el-table-column
  98. prop="enterpriseName"
  99. label="企业名称"
  100. width="200"
  101. sortable
  102. align="center"
  103. ></el-table-column>
  104. <el-table-column
  105. prop="code"
  106. label="所属行业"
  107. width="100"
  108. align="center"
  109. ></el-table-column>
  110. <el-table-column
  111. align="center"
  112. prop="year" label="年度" width="100"></el-table-column>
  113. <el-table-column
  114. prop="season"
  115. label="季度"
  116. width="100"
  117. align="center"
  118. sortable
  119. ></el-table-column>
  120. <el-table-column
  121. v-if="mode == 'trendAnalysis'"
  122. prop="trendAnalysis"
  123. label="趋势分析情况"
  124. width="300"
  125. ></el-table-column>
  126. <el-table-column
  127. v-if="mode == 'avgAnalysis'"
  128. prop="avgAnalysis"
  129. label="平均水平分析情况"
  130. width="350"
  131. ></el-table-column>
  132. <el-table-column
  133. prop="operationalEvaluate"
  134. label="企业运营评估结果参考"
  135. ></el-table-column>
  136. </el-table>
  137. <el-pagination
  138. @current-change="handlePageChange"
  139. :current-page="currentPage"
  140. :page-size="pageSize"
  141. :total="totalItems"
  142. hide-on-single-page
  143. background
  144. layout="total, prev, pager, next, jumper"
  145. style="float: right; margin-top: 20px; margin-bottom: 20px"
  146. >
  147. </el-pagination>
  148. <!-- <div ref="chart" :style="{ height: height, width: width }"></div> -->
  149. </div>
  150. </template>
  151. <script>
  152. import { listAllEnterprise } from "@/api/enterprise/enterprise";
  153. import { listAllIndustry } from "@/api/industry/industry";
  154. import { getIndexData } from "@/api/home";
  155. import { benefitList } from "@/api/benefit";
  156. export default {
  157. props: {
  158. className: {
  159. type: String,
  160. default: "chart",
  161. },
  162. width: {
  163. type: String,
  164. default: "100%",
  165. },
  166. height: {
  167. type: String,
  168. default: "400px",
  169. },
  170. },
  171. data() {
  172. return {
  173. selectedEnterpriseArray: [],
  174. EnterpriseArray: [],
  175. selectedYearArray: [],
  176. selectedIndustryArray: [],
  177. mode: "trendAnalysis",
  178. currentPage: 1,
  179. pageSize: 5,
  180. form: {
  181. enterpriseName: null,
  182. year: null,
  183. code: null,
  184. season: "1",
  185. mode: "trendAnalysis",
  186. },
  187. selectedAnalyseArray: [
  188. {
  189. key: "trendAnalysis",
  190. value: "趋势分析",
  191. },
  192. {
  193. key: "avgAnalysis",
  194. value: "平均水平分析",
  195. },
  196. ],
  197. selectedSeasonArray: [
  198. {
  199. key: "1",
  200. value: "1季度",
  201. },
  202. {
  203. key: "2",
  204. value: "2季度",
  205. },
  206. {
  207. key: "3",
  208. value: "3季度",
  209. },
  210. {
  211. key: "4",
  212. value: "4季度",
  213. },
  214. ],
  215. tableData: [],
  216. };
  217. },
  218. computed: {
  219. totalItems() {
  220. return this.tableData.length;
  221. },
  222. paginatedData() {
  223. const start = (this.currentPage - 1) * this.pageSize;
  224. return this.tableData.slice(start, start + this.pageSize);
  225. },
  226. },
  227. mounted() {
  228. this.init();
  229. },
  230. methods: {
  231. handlePageChange(newPage) {
  232. this.currentPage = newPage;
  233. },
  234. async init() {
  235. const that = this;
  236. // 获取所有的行业
  237. await listAllIndustry()
  238. .then((res) => {
  239. if (res && res?.rows) {
  240. that.selectedIndustryArray = res.rows.map((item) => {
  241. return {
  242. key: item.code,
  243. value: item.code + item.industryName,
  244. };
  245. });
  246. }
  247. })
  248. .catch((error) => {
  249. console.error("Error fetching data:", error);
  250. });
  251. // 获取所有的企业
  252. await listAllEnterprise()
  253. .then((res) => {
  254. if (res && res?.rows) {
  255. that.EnterpriseArray = res.rows.map((item) => {
  256. return {
  257. key: item.id,
  258. value: item.enterpriseName,
  259. code: item.code,
  260. };
  261. });
  262. }
  263. })
  264. .catch((error) => {
  265. console.error("Error fetching data:", error);
  266. });
  267. // 获取有的年份
  268. await getIndexData({
  269. year: 0,
  270. })
  271. .then((res) => {
  272. if (res && res?.rows) {
  273. that.selectedYearArray = res.rows[0].years.map((v) => {
  274. return {
  275. key: v,
  276. value: v,
  277. };
  278. });
  279. }
  280. })
  281. .catch((error) => {
  282. console.error("Error fetching data:", error);
  283. });
  284. // 第一次的时候初始化from
  285. this.resetForm();
  286. },
  287. submit() {
  288. benefitList(this.form)
  289. .then((res) => {
  290. if (res && res?.rows) {
  291. this.mode = this.form.mode;
  292. this.tableData = res.rows;
  293. }
  294. })
  295. .catch((error) => {
  296. console.error("Error fetching data:", error);
  297. });
  298. },
  299. resetForm() {
  300. // 过滤对应行业的的企业出来
  301. this.selectedEnterpriseArray = this.EnterpriseArray.filter(
  302. (item) => item.code == this.selectedIndustryArray[0].key
  303. );
  304. // 重置form表单
  305. this.form = {
  306. year: this.selectedYearArray[0].key,
  307. enterpriseName: null,
  308. code: this.selectedIndustryArray[0].key,
  309. season: null,
  310. mode: this.selectedAnalyseArray[0].key,
  311. };
  312. this.submit();
  313. },
  314. codeChange(e) {
  315. // 当选择的行业变化时,过滤对应行业的的企业出来
  316. this.selectedEnterpriseArray = this.EnterpriseArray.filter(
  317. (item) => item.code == e
  318. );
  319. this.form.enterpriseName = null;
  320. },
  321. },
  322. };
  323. </script>
  324. <style scoped>
  325. .select-container {
  326. margin: 10px 5px;
  327. font-size: 16px;
  328. }
  329. .select-container select {
  330. padding: 10px 20px;
  331. margin-right: 10px;
  332. border: 1px solid #121315;
  333. border-radius: 4px;
  334. background-color: white;
  335. color: #121315;
  336. font-size: 16px;
  337. cursor: pointer;
  338. outline: none;
  339. }
  340. .select-container select:hover {
  341. border-color: #1a7cc8;
  342. }
  343. .select-container select:focus {
  344. border-color: #121315;
  345. box-shadow: 0 0 0 2px rgba(64, 159, 255, 0.2);
  346. }
  347. </style>