Bläddra i källkod

公司制度上传

duy 2 år sedan
förälder
incheckning
e264e90ef8
2 ändrade filer med 102 tillägg och 24 borttagningar
  1. 22 0
      src/api/modules/people/companyRule.js
  2. 80 24
      src/views/people/company-rule.vue

+ 22 - 0
src/api/modules/people/companyRule.js

@@ -0,0 +1,22 @@
+import {httpApi} from "../../request/httpApi";
+
+export default {
+    //分页公司制度信息表
+    async getPage(form, msg = true) {
+        return httpApi({
+            url: '/api/blade-control/corporationinfo/page',
+            method: 'get',
+            params: form
+        }, msg);
+    },
+    //新增新制度
+    async save(form, msg = true) {
+        return httpApi({
+            url: '/api/blade-control/corporationinfo/save',
+            method: 'post',
+            data: form,
+            isDelay:true
+        }, msg);
+    },
+
+}

+ 80 - 24
src/views/people/company-rule.vue

@@ -2,40 +2,41 @@
 <template>
   <HcCard>
     <template #extra>
-            <HcUploadFile
-            :options="UploadFileOptions"
-            @progress="HcUploadFileProgress"
-            @success="HcUploadFileSuccess"
-            @change="HcUploadFileChange"
-        >
-            <el-button hc-btn type="primary">上传新制度</el-button>
-        </HcUploadFile>
+        <el-button hc-btn type="primary" @click="uoloadNewRule">上传新制度</el-button>
     </template>
-    <HcTable :column="tableColumn" :datas="tableData" >
+    <HcTable :column="tableColumn" :datas="tableData" :tableLoading="tableLoading">
             <template #name="{row}">
                         <div class="text-link text-blue"  @click="viewPdf(row)">{{row?.name}}</div>
             </template>
             <template #action="{row, index}">
-                <HcUploadFile
-                  :options="UploadFileOptions"
-                  @progress="HcUploadFileProgress"
-                  @success="HcUploadFileSuccess"
-                  @change="HcUploadFileChange"
-              >
-                  <el-button hc-btn type="primary" size="small">重新上传</el-button>
-              </HcUploadFile>
+                <el-button hc-btn type="primary" size="small" @click="replaceUoload">重新上传</el-button>
             </template>
       </HcTable>
       <template #action>
             <HcPages :pages="searchForm" @change="pageChange"></HcPages>
       </template>
+      <HcUploadFile
+            :echoParams="uploadEchoParams"
+            ref="HcUploadFileRef"
+            :options="UploadFileOptions"
+            @progress="HcUploadFileProgress"
+            @success="HcUploadFileSuccess"
+            @change="HcUploadFileChange" 
+            :url="'/blade-resource/oss/endpoint/upload-file'"
+        > 
+      </HcUploadFile>
   </HcCard>
 </template>
 
 <script setup>
-import {ref, watch} from  'vue'
+import {ref, watch,onActivated} from  'vue'
 import {getTokenHeader} from "~src/api/request/header";
-
+import companyRuleApi from '~api/people/companyRule.js';
+import {getArrValue,getObjValue} from "js-fast-way"
+onActivated(()=>{
+    getTableData()
+  
+})
 const tableColumn = [
     {key: 'name', name: '制度名称'},
     {key: 'action', name: '操作', width: 120}
@@ -46,8 +47,20 @@ const tableData = ref([
     {name: '名称2', },
     {name: '名称3', }
 ])
+const tableLoading=ref(false)
+const getTableData = async() => {
+    tableLoading.value = true
+    const {error, code, data} = await companyRuleApi.getPage(searchForm.value)
+    tableLoading.value = false
+    if (!error && code === 200) {
+        tableData.value = getArrValue(data['records'])
+        searchForm.value.total = data['total'] || 0
+    } else {
+        tableData.value = []
+        searchForm.value.total = 0
+    }
+}
 const searchForm = ref({
-    name: '',
     current: 1, size: 20, total: 0
 })
 //分页被点击
@@ -58,6 +71,8 @@ const pageChange = ({current, size}) => {
 
 
 //上传配置
+const HcUploadFileRef=ref(null)
+const uploadEchoParams = ref({})
 const UploadFileOptions = {
     // 此处设置header
     headers: getTokenHeader(),
@@ -68,17 +83,58 @@ const HcUploadFileProgress = (res) => {
     console.log('文件上传进度', res)
 }
 // 文件上传成功的回调
-const HcUploadFileSuccess = (res) => {
-    console.log('文件上传成功', res)
+const fileData=ref({})
+const HcUploadFileSuccess = ({echoParams, resData}) => {
+    fileData.value= getObjValue(resData)
+    HcUploadFileRef.value?.setModalShow(false);
+    const {name, index} = echoParams
+    if(name==='newRule'){
+        addRule(resData)
+    }
 }
 
+//新增制度
+const addRuleLoaing=ref(false)
+const addRule=async(resData)=>{
+console.log(resData,'res');
+addRuleLoaing.value=true
+const {error, code, data,msg} = await companyRuleApi.save(
+    {
+       
+
+
+    }
+)
+ 
+addRuleLoaing.value = false
+    if (!error && code === 200) {
+        window.$message.success(msg)
+        getTableData().then
+    } 
+
+
+}
 // 文件全部上传成功
 const HcUploadFileChange = () => {
     console.log('文件全部上传成功')
 }
+//上传新制度
+const uoloadNewRule=()=>{
+    HcUploadFileRef.value?.selectFile();
+    uploadEchoParams.value = {
+        name: 'newRule',
+    }
+}
+//上传新制度
+const replaceUoload=()=>{
+    HcUploadFileRef.value?.selectFile();
+    uploadEchoParams.value = {
+        name: 'replace',
+    }
+}
 //查看pdf
- const viewPdf=()=>{
-    window.open('http://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload/20230606/c339aec388bab8c36d3272fe93bae350.pdf', '_blank')
+ const viewPdf=(row)=>{
+    window.open(row?.link, '_blank')
  }
 </script>
 <style lang='scss' scoped>