zs 8 月之前
父節點
當前提交
ebaa5bb2fc
共有 2 個文件被更改,包括 160 次插入168 次删除
  1. 0 164
      src/views/applyCompany/index.vue
  2. 160 4
      src/views/exam/parts/company.vue

+ 0 - 164
src/views/applyCompany/index.vue

@@ -1,164 +0,0 @@
-<template>
-  <div class="main animate__animated animate__backInRight" v-loading="loading">
-    <custom-search-bar :fields="fields.filter((f) => f.isSearch)" v-model="searchForm" @search="search" @reset="toReset"> </custom-search-bar>
-    <custom-table :data="data" :fields="fields" @query="search" :total="total" :opera="opera" @view="toView" @exam="toExam">
-      <template #is_use="{ row }">
-        <el-tag v-if="row.is_use == '0'" type="success" @click="toUse(row, '1')">启用</el-tag>
-        <el-tag v-else type="info" @click="toUse(row, '0')">禁用</el-tag>
-      </template>
-    </custom-table>
-    <el-dialog v-model="dialog.show" :title="dialog.title" :destroy-on-close="false" @close="toClose">
-      <el-row>
-        <el-col :span="24" v-if="dialog.type == '1'">
-          <custom-form v-model="form" :fields="formFields" :rules="rules" @save="toSave">
-            <template #file>
-              <custom-upload model="file" :list="form.file" :limit="1" listType="picture-card" url="/files/web/cxyy_applyCompany/upload" @change="onUpload"></custom-upload>
-            </template>
-            <template #card>
-              <custom-upload model="card" :list="form.card" :limit="2" listType="picture-card" url="/files/web/cxyy_applyCompany/upload" @change="onUpload"></custom-upload>
-            </template>
-          </custom-form>
-        </el-col>
-        <el-col :span="24" v-if="dialog.type == '2'">
-          <custom-form v-model="examForm" :fields="examFormFields" :rules="examRules" @save="toExamSave">
-            <template #status>
-              <el-option v-for="i in statusList" :key="i.id" :label="i.label" :value="i.value"></el-option>
-            </template>
-          </custom-form>
-        </el-col>
-      </el-row>
-    </el-dialog>
-  </div>
-</template>
-
-<script setup>
-import { cloneDeep, get } from 'lodash-es'
-const $checkRes = inject('$checkRes')
-const { t } = useI18n()
-// 接口
-import { ApplyCompanyStore } from '@/store/api/user/applyCompany'
-import { DictDataStore } from '@/store/api/system/dictData'
-const store = ApplyCompanyStore()
-const dictDataStore = DictDataStore()
-const data = ref([])
-const searchForm = ref({})
-const fields = [
-  { label: t('pages.applyCompany.company_name'), model: 'company_name' },
-  { label: t('pages.applyCompany.user_name'), model: 'user_name' },
-  { label: t('pages.applyCompany.person'), model: 'person', isSearch: true },
-  { label: t('pages.applyCompany.person_phone'), model: 'person_phone', isSearch: true },
-  { label: t('pages.applyCompany.status'), model: 'status', format: (i) => getDict(i, 'status') }
-]
-const opera = [
-  { label: t('common.view'), method: 'view' },
-  { label: t('common.exam'), method: 'exam', type: 'warning', display: (i) => i.status === '0' }
-]
-let skip = 0
-let limit = inject('limit')
-const total = ref(0)
-const statusList = ref([])
-// 加载中
-const loading = ref(false)
-const formFields = ref([
-  { label: t('pages.applyCompany.file'), model: 'file', custom: true },
-  { label: t('pages.applyCompany.person'), model: 'person' },
-  { label: t('pages.applyCompany.person_phone'), model: 'person_phone' },
-  { label: t('pages.applyCompany.card'), model: 'card', custom: true }
-])
-const rules = reactive({})
-const dialog = ref({ type: '1', show: false, title: t('pages.applyCompany.addDialogTitle') })
-const form = ref({ file: [] })
-// 审核
-const examFormFields = [{ label: t('pages.applyCompany.status'), model: 'status', type: 'select' }]
-const examRules = reactive({ status: [{ required: true, message: t('common.statusMessage'), trigger: 'blur' }] })
-const examForm = ref({})
-// 请求
-onMounted(async () => {
-  loading.value = true
-  await searchOther()
-  await search({ skip, limit })
-  loading.value = false
-})
-
-const searchOther = async () => {
-  let result
-  // 状态
-  result = await dictDataStore.query({ code: 'examStatus', is_use: '0' })
-  if ($checkRes(result)) statusList.value = result.data
-}
-const search = async (query = { skip, limit }) => {
-  skip = query.skip
-  limit = query.limit
-  const info = { skip: query.skip, limit: query.limit, ...searchForm.value }
-  const res = await store.query(info)
-  if (res.errcode == '0') {
-    data.value = res.data
-    total.value = res.total
-  }
-}
-// 字典数据转换
-const getDict = (data, model) => {
-  if (data) {
-    let res
-    if (model == 'status') res = statusList.value.find((f) => f.value == data)
-    return get(res, 'label')
-  }
-}
-
-// 查看信息
-const toView = (data) => {
-  form.value = data
-  dialog.value = { type: '1', show: true, title: t('pages.applyCompany.viewDialogTitle') }
-}
-// 上传图片
-const onUpload = (e) => {
-  const { model, value } = e
-  form.value[model] = value
-}
-const toSave = async () => {
-  const data = cloneDeep(form.value)
-  const other = { status: '0' }
-  let res
-  if (get(data, 'id')) res = await store.update({ ...data, ...other })
-  else res = await store.create({ ...data, ...other })
-  if ($checkRes(res, true)) {
-    search({ skip, limit })
-    toClose()
-  }
-}
-// 审核
-const toExam = (data) => {
-  examForm.value = data
-  dialog.value = { type: '2', show: true, title: t('pages.applyCompany.examDialogTitle') }
-}
-// 审核保存
-const toExamSave = async () => {
-  const data = cloneDeep(examForm.value)
-  let res = await store.examine({ id: data.id, status: data.status })
-  if ($checkRes(res, true)) {
-    search({ skip, limit })
-    toClose()
-  }
-}
-// 开启或禁用
-const toUse = async (data, is_use) => {
-  ElMessageBox.confirm(`确定修改【${data.name}】数据?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' })
-    .then(async () => {
-      let res = await store.update({ id: get(data, 'id'), is_use, status: get(data, 'status') })
-      if ($checkRes(res, true)) {
-        search({ skip, limit })
-      }
-    })
-    .catch(() => {})
-}
-const toClose = () => {
-  form.value = { file: [] }
-  dialog.value = { show: false }
-}
-// 重置
-const toReset = async () => {
-  searchForm.value = {}
-  await search({ skip, limit })
-}
-</script>
-<style scoped lang="scss"></style>

+ 160 - 4
src/views/exam/parts/company.vue

@@ -1,8 +1,164 @@
 <template>
-  <div id="company">
-    <p>company</p>
+  <div id="company" v-loading="loading">
+    <custom-search-bar :fields="fields.filter((f) => f.isSearch)" v-model="searchForm" @search="search" @reset="toReset"> </custom-search-bar>
+    <custom-table :data="data" :fields="fields" @query="search" :total="total" :opera="opera" @view="toView" @exam="toExam">
+      <template #is_use="{ row }">
+        <el-tag v-if="row.is_use == '0'" type="success" @click="toUse(row, '1')">启用</el-tag>
+        <el-tag v-else type="info" @click="toUse(row, '0')">禁用</el-tag>
+      </template>
+    </custom-table>
+    <el-dialog v-model="dialog.show" :title="dialog.title" :destroy-on-close="false" @close="toClose">
+      <el-row>
+        <el-col :span="24" v-if="dialog.type == '1'">
+          <custom-form v-model="form" :fields="formFields" :rules="rules" @save="toSave">
+            <template #file>
+              <custom-upload model="file" :list="form.file" :limit="1" listType="picture-card" url="/files/web/cxyy_applyCompany/upload" @change="onUpload"></custom-upload>
+            </template>
+            <template #card>
+              <custom-upload model="card" :list="form.card" :limit="2" listType="picture-card" url="/files/web/cxyy_applyCompany/upload" @change="onUpload"></custom-upload>
+            </template>
+          </custom-form>
+        </el-col>
+        <el-col :span="24" v-if="dialog.type == '2'">
+          <custom-form v-model="examForm" :fields="examFormFields" :rules="examRules" @save="toExamSave">
+            <template #status>
+              <el-option v-for="i in statusList" :key="i.id" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </custom-form>
+        </el-col>
+      </el-row>
+    </el-dialog>
   </div>
 </template>
 
-<script setup></script>
-<style scoped></style>
+<script setup>
+import { cloneDeep, get } from 'lodash-es'
+const $checkRes = inject('$checkRes')
+const { t } = useI18n()
+// 接口
+import { ApplyCompanyStore } from '@/store/api/user/applyCompany'
+import { DictDataStore } from '@/store/api/system/dictData'
+const store = ApplyCompanyStore()
+const dictDataStore = DictDataStore()
+const data = ref([])
+const searchForm = ref({})
+const fields = [
+  { label: t('pages.applyCompany.company_name'), model: 'company_name' },
+  { label: t('pages.applyCompany.user_name'), model: 'user_name' },
+  { label: t('pages.applyCompany.person'), model: 'person', isSearch: true },
+  { label: t('pages.applyCompany.person_phone'), model: 'person_phone', isSearch: true },
+  { label: t('pages.applyCompany.status'), model: 'status', format: (i) => getDict(i, 'status') }
+]
+const opera = [
+  { label: t('common.view'), method: 'view' },
+  { label: t('common.exam'), method: 'exam', type: 'warning', display: (i) => i.status === '0' }
+]
+let skip = 0
+let limit = inject('limit')
+const total = ref(0)
+const statusList = ref([])
+// 加载中
+const loading = ref(false)
+const formFields = ref([
+  { label: t('pages.applyCompany.file'), model: 'file', custom: true },
+  { label: t('pages.applyCompany.person'), model: 'person' },
+  { label: t('pages.applyCompany.person_phone'), model: 'person_phone' },
+  { label: t('pages.applyCompany.card'), model: 'card', custom: true }
+])
+const rules = reactive({})
+const dialog = ref({ type: '1', show: false, title: t('pages.applyCompany.addDialogTitle') })
+const form = ref({ file: [] })
+// 审核
+const examFormFields = [{ label: t('pages.applyCompany.status'), model: 'status', type: 'select' }]
+const examRules = reactive({ status: [{ required: true, message: t('common.statusMessage'), trigger: 'blur' }] })
+const examForm = ref({})
+// 请求
+onMounted(async () => {
+  loading.value = true
+  await searchOther()
+  await search({ skip, limit })
+  loading.value = false
+})
+
+const searchOther = async () => {
+  let result
+  // 状态
+  result = await dictDataStore.query({ code: 'examStatus', is_use: '0' })
+  if ($checkRes(result)) statusList.value = result.data
+}
+const search = async (query = { skip, limit }) => {
+  skip = query.skip
+  limit = query.limit
+  const info = { skip: query.skip, limit: query.limit, ...searchForm.value }
+  const res = await store.query(info)
+  if (res.errcode == '0') {
+    data.value = res.data
+    total.value = res.total
+  }
+}
+// 字典数据转换
+const getDict = (data, model) => {
+  if (data) {
+    let res
+    if (model == 'status') res = statusList.value.find((f) => f.value == data)
+    return get(res, 'label')
+  }
+}
+
+// 查看信息
+const toView = (data) => {
+  form.value = data
+  dialog.value = { type: '1', show: true, title: t('pages.applyCompany.viewDialogTitle') }
+}
+// 上传图片
+const onUpload = (e) => {
+  const { model, value } = e
+  form.value[model] = value
+}
+const toSave = async () => {
+  const data = cloneDeep(form.value)
+  const other = { status: '0' }
+  let res
+  if (get(data, 'id')) res = await store.update({ ...data, ...other })
+  else res = await store.create({ ...data, ...other })
+  if ($checkRes(res, true)) {
+    search({ skip, limit })
+    toClose()
+  }
+}
+// 审核
+const toExam = (data) => {
+  examForm.value = data
+  dialog.value = { type: '2', show: true, title: t('pages.applyCompany.examDialogTitle') }
+}
+// 审核保存
+const toExamSave = async () => {
+  const data = cloneDeep(examForm.value)
+  let res = await store.examine({ id: data.id, status: data.status })
+  if ($checkRes(res, true)) {
+    search({ skip, limit })
+    toClose()
+  }
+}
+// 开启或禁用
+const toUse = async (data, is_use) => {
+  ElMessageBox.confirm(`确定修改【${data.name}】数据?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' })
+    .then(async () => {
+      let res = await store.update({ id: get(data, 'id'), is_use, status: get(data, 'status') })
+      if ($checkRes(res, true)) {
+        search({ skip, limit })
+      }
+    })
+    .catch(() => {})
+}
+const toClose = () => {
+  form.value = { file: [] }
+  dialog.value = { show: false }
+}
+// 重置
+const toReset = async () => {
+  searchForm.value = {}
+  await search({ skip, limit })
+}
+</script>
+<style scoped lang="scss"></style>