index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <template>
  2. <div class="financing-applications">
  3. <!-- 搜索板块 -->
  4. <el-row :gutter="20">
  5. <el-col style="display:flex" :span="20" :xs="24">
  6. <el-form :model="searchCondition" :inline="true">
  7. <el-form-item label="联系人" prop="contactPerson">
  8. <el-input
  9. v-model="searchCondition.contactPerson"
  10. style="max-width: 600px"
  11. placeholder="请输入联系人"
  12. class="input-with-select"
  13. :clearable="true"
  14. @change="handleSearch"
  15. >
  16. </el-input>
  17. </el-form-item>
  18. <el-form-item label="描述" prop="demandDescription">
  19. <el-input
  20. v-model="searchCondition.demandDescription"
  21. style="max-width: 600px"
  22. placeholder="请输入描述"
  23. class="input-with-select"
  24. :clearable="true"
  25. @change="handleSearch"
  26. >
  27. </el-input>
  28. </el-form-item>
  29. <el-form-item>
  30. <el-button type="primary" icon="Search" @click="handleSearch">搜索</el-button>
  31. <el-button icon="Refresh" @click="handleReset">重置</el-button>
  32. </el-form-item>
  33. </el-form>
  34. </el-col>
  35. </el-row>
  36. <el-button
  37. type="primary"
  38. icon="Plus"
  39. @click="showApplicationLoanDialog"
  40. plain
  41. style="margin-bottom: 20px"
  42. >
  43. 申&nbsp;&nbsp;请
  44. </el-button>
  45. <div style="margin: auto">
  46. <el-empty v-if="!applications.length" description="暂无数据" :image-size="100"/>
  47. </div>
  48. <el-row :gutter="20" v-loading="loading">
  49. <el-col :span="8" v-for="(application, index) in applications" :key="index" >
  50. <el-card class="financing-card" shadow="hover">
  51. <div class="card-header">
  52. <h3>{{ application.enterpriseName }}</h3>
  53. <div class="actions">
  54. <el-button size="small" type="primary" @click="handleEdit(application.id)">编辑</el-button>
  55. <el-popconfirm
  56. confirm-button-text="发布"
  57. cancel-button-text="再改改"
  58. :icon="InfoFilled"
  59. icon-color="#626AEF"
  60. title="确定发布?发布后将不可修改"
  61. @confirm="handleRelease(application.id)"
  62. >
  63. <template #reference>
  64. <el-button size="small" type="danger">发布</el-button>
  65. </template>
  66. </el-popconfirm>
  67. </div>
  68. </div>
  69. <div class="card-content">
  70. <div class="card-item">
  71. <span class="label">企业统一社会信用编码:</span>
  72. <span class="value">{{ application.unifiedSocialCreditCode }}</span>
  73. </div>
  74. <div class="card-item">
  75. <span class="label">企业名称:</span>
  76. <span class="value">{{ application.enterpriseName }}</span>
  77. </div>
  78. <div class="card-item">
  79. <span class="label">联系人:</span>
  80. <span class="value">{{ application.contactPerson }}</span>
  81. </div>
  82. <div class="card-item">
  83. <span class="label">联系方式:</span>
  84. <span class="value">{{ application.contactMethod }}</span>
  85. </div>
  86. <div class="card-item">
  87. <span class="label">需求金额:</span>
  88. <span class="value">{{ application.requiredAmount }}</span>
  89. </div>
  90. <div class="card-item">
  91. <span class="label">状态:</span>
  92. <el-tag :type="getStatusType(application.status)">
  93. {{ formatStatus(application.status) }}
  94. </el-tag>
  95. </div>
  96. <div class="card-item">
  97. <span class="label">需求描述:</span>
  98. <span class="value" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">{{ application.demandDescription }}</span>
  99. </div>
  100. <div class="card-item">
  101. <span class="label">创建时间:</span>
  102. <span class="value">{{ application.createTime ? formatDateTime(application.createTime) : '-' }}</span>
  103. </div>
  104. </div>
  105. </el-card>
  106. </el-col>
  107. </el-row>
  108. <el-dialog
  109. v-model="loanDialogVisible"
  110. :title="loanTitle"
  111. align-center
  112. >
  113. <template #default>
  114. <el-form ref="loanFormRef" :model="loanForm" label-width="150px" :rules="loanRules">
  115. <el-form-item label="企业统一社会信用编码" prop="unifiedSocialCreditCode">
  116. <el-input v-model="loanForm.unifiedSocialCreditCode" disabled></el-input>
  117. </el-form-item>
  118. <el-form-item label="企业名称" prop="enterpriseName">
  119. <el-input v-model="loanForm.enterpriseName" disabled></el-input>
  120. </el-form-item>
  121. <el-form-item label="联系人" prop="contactPerson">
  122. <el-input v-model="loanForm.contactPerson"></el-input>
  123. </el-form-item>
  124. <el-form-item label="联系方式" prop="contactMethod">
  125. <el-input v-model="loanForm.contactMethod"></el-input>
  126. </el-form-item>
  127. <el-form-item label="需求金额" prop="requiredAmount">
  128. <el-input-number v-model.number="loanForm.requiredAmount" :step="10000" :min="10000" :max="5000000"></el-input-number>
  129. </el-form-item>
  130. <el-form-item label="需求描述" prop="demandDescription">
  131. <el-input type="textarea" v-model="loanForm.demandDescription"></el-input>
  132. </el-form-item>
  133. </el-form>
  134. </template>
  135. <template #footer>
  136. <div class="dialog-footer">
  137. <el-button @click="loanDialogVisible = false">取消</el-button>
  138. <el-button type="primary" @click="submitLoanForm">确认</el-button>
  139. </div>
  140. </template>
  141. </el-dialog>
  142. <div>
  143. <el-pagination
  144. background
  145. layout="prev, pager, next, ->,total"
  146. :total="total"
  147. v-model:page-size="pageSize"
  148. v-model:current-page="currentPage"
  149. @current-change="list"
  150. ></el-pagination>
  151. </div>
  152. </div>
  153. </template>
  154. <script setup>
  155. import {reactive, ref} from 'vue';
  156. import { ElMessage } from 'element-plus';
  157. import {addOrUpdateLoanApplication, getLoanById, listByPage, releaseApplicationById} from "@/api/xyrz/rzsq";
  158. import {useStore} from "vuex";
  159. import {InfoFilled} from "@element-plus/icons-vue";
  160. const loading = ref(false);
  161. const store = useStore();
  162. const loanDialogVisible = ref(false);
  163. const loanFormRef = ref(null);
  164. const loanTitle = ref('');
  165. const applications = ref([]);
  166. const total = ref(0);
  167. const pageSize = ref(3);
  168. const currentPage = ref(1);
  169. const showApplicationLoanDialog = ()=>{
  170. loanTitle.value = '提交贷款申请'
  171. loanForm.contactMethod = ''
  172. loanForm.contactPerson = ''
  173. loanForm.demandDescription = ''
  174. loanForm.requiredAmount = ''
  175. loanForm.id = null;
  176. loanForm.enterpriseName = store.getters.userInfo.nickName
  177. loanForm.unifiedSocialCreditCode = store.getters.userInfo.userName
  178. loanDialogVisible.value = true;
  179. loanFormRef.resetFields();
  180. }
  181. const searchCondition = ref({
  182. contactPerson: undefined,
  183. demandDescription: undefined,
  184. })
  185. const handleSearch = () => {
  186. list()
  187. }
  188. const handleReset = () => {
  189. searchCondition.value = {}
  190. list()
  191. }
  192. const initLoanForm = {
  193. unifiedSocialCreditCode: '',
  194. enterpriseName: '',
  195. contactPerson: '',
  196. contactMethod: '',
  197. requiredAmount: '',
  198. demandDescription: '',
  199. }
  200. const loanForm = reactive(initLoanForm);
  201. const loanRules = reactive({
  202. unifiedSocialCreditCode: [{ required: true, message: '请输入企业统一社会信用编码', trigger: 'blur' }],
  203. enterpriseName: [{ required: true, message: '请输入企业名称', trigger: 'blur' }],
  204. contactPerson: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
  205. contactMethod: [
  206. { required: true, message: '请输入联系方式', trigger: 'blur' },
  207. {
  208. pattern: /^1[3456789]\d{9}$/,
  209. message: '请输入正确的手机号码',
  210. trigger: 'blur'
  211. }
  212. ],
  213. requiredAmount: [{ required: true, message: '请输入需求金额', trigger: 'blur' }],
  214. demandDescription: [{ required: true, message: '请输入需求描述', trigger: 'blur' }],
  215. });
  216. const submitLoanForm = () => {
  217. loanFormRef.value.validate(async (valid) => {
  218. if (valid) {
  219. // 提交表单逻辑
  220. const res = await addOrUpdateLoanApplication(loanForm);
  221. if(res.code != 200){
  222. ElMessage.error(res.msg);
  223. return false;
  224. }
  225. ElMessage.success(res.msg);
  226. list()
  227. loanDialogVisible.value = false;
  228. loanFormRef.resetFields();
  229. } else {
  230. return false;
  231. }
  232. list();
  233. });
  234. };
  235. const handleEdit = async (id) => {
  236. loanTitle.value = '编辑贷款申请'
  237. const res = await getLoanById(id);
  238. if(res.code == 200){
  239. loanForm.unifiedSocialCreditCode = res.data.unifiedSocialCreditCode;
  240. loanForm.enterpriseName = res.data.enterpriseName;
  241. loanForm.contactPerson = res.data.contactPerson;
  242. loanForm.contactMethod = res.data.contactMethod;
  243. loanForm.requiredAmount = res.data.requiredAmount;
  244. loanForm.demandDescription = res.data.demandDescription;
  245. loanForm.id = res.data.id;
  246. loanDialogVisible.value = true;
  247. }
  248. // 这里可以添加编辑逻辑
  249. };
  250. const handleRelease = async (id) => {
  251. const res = await releaseApplicationById(id);
  252. if(res.code != 200){
  253. ElMessage.error(res.msg);
  254. }
  255. ElMessage.success(res.msg);
  256. list()
  257. };
  258. const formatStatus = (status) => {
  259. switch (status) {
  260. case 0:
  261. return '待发布';
  262. case 1:
  263. return '待审核';
  264. case 2:
  265. return '已放款';
  266. case 3:
  267. return '未放款';
  268. case 4:
  269. return '已撤销';
  270. default:
  271. return '未知状态';
  272. }
  273. };
  274. const getStatusType = (status) => {
  275. switch (status) {
  276. case 0:
  277. return 'warning';
  278. case 1:
  279. return 'warning';
  280. case 2:
  281. return 'success';
  282. case 3:
  283. return 'danger';
  284. case 4:
  285. return 'info';
  286. default:
  287. return 'default';
  288. }
  289. };
  290. // 格式化日期时间
  291. function formatDateTime(dateTime) {
  292. if (!dateTime) return '';
  293. const date = new Date(dateTime);
  294. return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}:${String(date.getSeconds()).padStart(2, '0')}`;
  295. }
  296. const list =async ()=>{
  297. const conditionJsonArr = [];
  298. conditionJsonArr.push(
  299. {
  300. column:"unified_social_credit_code",
  301. type:'eq',
  302. value:store.getters.userInfo.userName,
  303. },
  304. {
  305. column:"create_time",
  306. type:'orderByDesc'
  307. },
  308. {
  309. column:"status",
  310. type:'eq',
  311. value:0
  312. }
  313. )
  314. searchCondition.value.contactPerson && conditionJsonArr.push({
  315. column: "contact_person",
  316. type: 'like',
  317. value: searchCondition.value.contactPerson
  318. })
  319. searchCondition.value.demandDescription && conditionJsonArr.push({
  320. column: "demand_description",
  321. type: 'like',
  322. value: searchCondition.value.demandDescription
  323. })
  324. loading.value = true;
  325. const res = await listByPage(currentPage.value,pageSize.value,conditionJsonArr);
  326. if(res.code != 200){
  327. ElMessage.error(res.msg);
  328. }
  329. applications.value = res.data.records;
  330. total.value = res.data.total
  331. loading.value = false;
  332. }
  333. list()
  334. </script>
  335. <style scoped>
  336. .financing-applications {
  337. margin: 20px;
  338. }
  339. .financing-card {
  340. margin-bottom: 20px;
  341. }
  342. .card-header {
  343. display: flex;
  344. justify-content: space-between;
  345. align-items: center;
  346. }
  347. .card-item {
  348. display: flex;
  349. justify-content: space-between;
  350. margin-bottom: 10px;
  351. }
  352. .label {
  353. font-weight: bold;
  354. width: 40%;
  355. }
  356. .value {
  357. width: 60%;
  358. }
  359. </style>