company.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <div class="index">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
  5. <div class="one">
  6. <el-select size="large" style="width: 350px" clearable v-model="company_id" filterable remote reserve-keyword placeholder="请输入想要选择的企业" :remote-method="remoteMethod" :loading="searchLoading">
  7. <el-option v-for="item in searchList" :key="item.id" :label="item.name" :value="item.id" />
  8. </el-select>
  9. <el-button class="button" size="large" @click="toSave" type="primary">确定</el-button>
  10. </div>
  11. <el-col :span="24" class="two">
  12. <el-table :data="list" style="width: 100%" size="large" :header-cell-style="{ backgroundColor: '#edf3ff' }">
  13. <template #empty>
  14. <el-empty description="暂无数据" />
  15. </template>
  16. <el-table-column prop="company_name" align="center" label="企业名称" />
  17. <el-table-column prop="incubator_name" align="center" label="孵化器名称" />
  18. <el-table-column prop="time" align="center" label="申请时间" width="180" />
  19. <el-table-column prop="status" align="center" label="状态" width="180">
  20. <template #default="scope">
  21. <div>{{ getDict(scope.row.status, 'status') }}</div>
  22. </template>
  23. </el-table-column>
  24. <el-table-column align="center" label="操作" width="180">
  25. <template #default="{ row }">
  26. <el-link v-if="row.status == '0'" :underline="false" type="warning" size="mini" @click="toExam(row)" style="margin-right: 10px">提交审核</el-link>
  27. <el-link :underline="false" type="danger" size="mini" @click="toDelete(row)"> 删除 </el-link>
  28. </template>
  29. </el-table-column>
  30. </el-table>
  31. </el-col>
  32. <el-col :span="24" class="thr">
  33. <el-pagination background layout="prev, pager, next" :total="total" :page-size="limit" v-model:current-page="currentPage" @current-change="changePage" @size-change="sizeChange" />
  34. </el-col>
  35. </el-col>
  36. </el-row>
  37. <el-dialog v-model="dialog.show" :title="dialog.title" :destroy-on-close="false" @close="toClose">
  38. <el-row>
  39. <el-col :span="24" v-if="dialog.type == '1'">
  40. <custom-form v-model="examForm" :fields="examFormFields" :rules="examRules" @save="toExamSave" :DraftSave="false" submitText="提交">
  41. <template #status>
  42. <el-option v-for="i in statusList" :key="i.id" :label="i.label" :value="i.value"></el-option>
  43. </template>
  44. </custom-form>
  45. </el-col>
  46. </el-row>
  47. </el-dialog>
  48. </div>
  49. </template>
  50. <script setup>
  51. import { cloneDeep, get } from 'lodash-es'
  52. import moment from 'moment'
  53. import { UserStore } from '@/store/user'
  54. const userStore = UserStore()
  55. const user = computed(() => userStore.user)
  56. const $checkRes = inject('$checkRes')
  57. // 接口
  58. import { CompanyStore } from '@/store/api/user/company'
  59. import { CirelationStore } from '@/store/api/user/cirelation'
  60. import { IncubatorStore } from '@/store/api/user/incubator'
  61. import { DictDataStore } from '@/store/api/system/dictData'
  62. const incubatorStore = IncubatorStore()
  63. const store = CompanyStore()
  64. const cirelationStore = CirelationStore()
  65. const dictDataStore = DictDataStore()
  66. // 加载中
  67. const loading = ref(false)
  68. const searchLoading = ref(false)
  69. const searchList = ref([])
  70. const company_id = ref('')
  71. const incubatorInfo = ref({})
  72. // 字典表
  73. const statusList = ref([])
  74. // 列表
  75. const list = ref([])
  76. let skip = 0
  77. let limit = inject('limit')
  78. const total = ref(0)
  79. const currentPage = ref(1)
  80. const dialog = ref({ type: '1', show: false, title: '审核' })
  81. // 审核
  82. const examFormFields = [{ label: '状态', model: 'status', type: 'select' }]
  83. const examRules = reactive({ status: [{ required: true, message: '请选择状态', trigger: 'blur' }] })
  84. const examForm = ref({})
  85. // 请求
  86. onMounted(async () => {
  87. loading.value = true
  88. await searchOther()
  89. await search()
  90. loading.value = false
  91. })
  92. const searchOther = async () => {
  93. let result
  94. // 状态
  95. result = await dictDataStore.query({ code: 'examStatus', is_use: '0' })
  96. if ($checkRes(result)) statusList.value = result.data
  97. if (user.value.id) {
  98. let res = await incubatorStore.query({ user: user.value.id, status: '1' })
  99. if (res.errcode == '0') {
  100. if (!res.data[0].logo) res.data[0].logo = []
  101. incubatorInfo.value = res.data[0] || { logo: [] }
  102. }
  103. }
  104. }
  105. const search = async (query = { skip, limit }) => {
  106. skip = query.skip
  107. limit = query.limit
  108. const info = {
  109. skip: query.skip,
  110. limit: query.limit,
  111. incubator: incubatorInfo.value.id
  112. }
  113. const res = await cirelationStore.list(info)
  114. if (res.errcode == '0') {
  115. list.value = res.data
  116. total.value = res.total
  117. }
  118. }
  119. const remoteMethod = (query) => {
  120. if (query) {
  121. searchLoading.value = true
  122. setTimeout(async () => {
  123. searchLoading.value = false
  124. const info = { status: '1', name: query }
  125. const res = await store.query(info)
  126. if (res.errcode == '0') searchList.value = res.data
  127. }, 200)
  128. } else {
  129. searchList.value = []
  130. }
  131. }
  132. // 字典数据转换
  133. const getDict = (data, model) => {
  134. if (data) {
  135. let res
  136. if (model == 'status') res = statusList.value.find((f) => f.value == data)
  137. return get(res, 'label')
  138. }
  139. }
  140. // 删除
  141. const toDelete = (data) => {
  142. ElMessageBox.confirm(`您确认删除该数据?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' })
  143. .then(async () => {
  144. const res = await cirelationStore.del(data.id)
  145. if ($checkRes(res, true)) {
  146. search({ skip, limit })
  147. }
  148. })
  149. .catch(() => {})
  150. }
  151. const toSave = () => {
  152. ElMessageBox.confirm(`您确认选择该数据?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' })
  153. .then(async () => {
  154. const data = {
  155. user: user.value.id,
  156. incubator: incubatorInfo.value.id,
  157. company: company_id.value,
  158. time: moment().format('YYYY-MM-DD'),
  159. status: '1'
  160. }
  161. const res = await cirelationStore.create(data)
  162. if ($checkRes(res, true)) {
  163. search({ skip, limit })
  164. }
  165. company_id.value = ''
  166. })
  167. .catch(() => {})
  168. }
  169. // 审核
  170. const toExam = (data) => {
  171. examForm.value = data
  172. dialog.value = { type: '1', show: true, title: '审核' }
  173. }
  174. // 审核保存
  175. const toExamSave = async () => {
  176. const data = cloneDeep(examForm.value)
  177. let res = await cirelationStore.update({ id: data.id, status: data.status })
  178. if ($checkRes(res, true)) {
  179. search({ skip, limit })
  180. toClose()
  181. }
  182. }
  183. const toClose = () => {
  184. examForm.value = {}
  185. dialog.value = { show: false }
  186. }
  187. // 分页
  188. const changePage = (page = currentPage.value) => {
  189. search({ skip: (page - 1) * limit, limit: limit })
  190. }
  191. const sizeChange = (limits) => {
  192. limit = limits
  193. currentPage.value = 1
  194. search({ skip: 0, limit: limit })
  195. }
  196. </script>
  197. <style scoped lang="scss">
  198. .main {
  199. .one {
  200. display: flex;
  201. align-items: center;
  202. margin: 0 0 10px 0;
  203. .button {
  204. margin: 0 0 0 5px;
  205. }
  206. }
  207. .thr {
  208. display: flex;
  209. justify-content: center;
  210. margin: 20px 0 0 0;
  211. }
  212. }
  213. </style>