Jelajahi Sumber

企业管理2

username 4 hari lalu
induk
melakukan
2713a98753

+ 6 - 0
src/api/company.js

@@ -14,4 +14,10 @@ export const getSystemTxAllStripLineInfo=(data)=>{
 export const getCompanyBtSelectBatchCompanyList=(data)=>{
     const url = zlbApi.getCompanyBtSelectBatchCompanyList;
     return myFetch(url, 'get', data, 'json');
+}
+
+// 企业新增
+export const postCompanyBtAddCompany = (data) => {
+	const url = zlbApi.postCompanyBtAddCompany; // '/callingPolice/selectPageData'
+	return myFetch(url, 'post', data, 'json');
 }

+ 1 - 0
src/api/zlbApi.js

@@ -134,6 +134,7 @@ const zlbApi = {
     "getSystemBpAllTabInfo":"/system/bq/allTabInfo", // 获取兴趣点数据
     "getSystemTxAllStripLineInfo":'/system/tx/allStripLineInfo',
     "getCompanyBtSelectBatchCompanyList":"/company/bt/selectBatchCompanyList", // 企业批量查询
+    "postCompanyBtAddCompany":"/company/bt/addCompany", // 企业新增
 }
 
 export default zlbApi;

+ 102 - 31
src/subPages/pages/companyManage/search/com/addCompany.vue

@@ -1,30 +1,42 @@
 <!-- 企业新增 -->
 <template>
-    <view>
-        <view class="titleStyle">基本信息</view>
-        <van-cell-group inset>
-            <van-field input-align="right" label="招牌名称" v-model="newData.signboardName" placeholder="请输入" />
-            <van-field input-align="right" label="统一社会信用代码" v-model="newData.creditCode" placeholder="请输入" />
-            <van-field input-align="right" class="red-star" label="企业名称" v-model="newData.companyName" placeholder="请输入" :rules="[{ validator, message: '请输入' }]"/>
-            <van-field input-align="right" label="注册资本" v-model="newData.registerCapital" placeholder="请输入" />
-            <van-field input-align="right" class="red-star" v-model="newData.state" is-link readonly name="picker" label="经营状态" placeholder="请选择"
-                @click="statePricker = true" />
-            <van-popup v-model:show="statePricker" position="bottom" round>
-                <van-picker :columns="columns" @confirm="onConfirm" @cancel="cancel" show-toolbar />
-            </van-popup>
-            <van-field input-align="right" label="备注" v-model="newData.remark" placeholder="请输入" />
-        </van-cell-group>
-        <view class="buttonStyle">
-            <van-button color="#1989fa" @click="closeFn" size="small"
-                style="width: 25%; border-radius: 8px;">取消</van-button>
-            <van-button color="#1989fa" @click="submitFn" size="small"
-                style="width: 25%; border-radius: 8px;">保存</van-button>
+    <view class="page-container">
+        <view class="container-center">
+            <view class="box">
+
+                <view class="title">
+                    <text>
+                        基本信息
+                    </text>
+                </view>
+                <van-form ref="searchFromRef" class="content">
+                    <van-field input-align="right" label="招牌名称" v-model="newData.signboardName" placeholder="请输入" />
+                    <van-field input-align="right" label="统一社会信用代码" v-model="newData.creditCode" placeholder="请输入"
+                        label-width="8em" />
+                    <van-field input-align="right" class="red-star" label="企业名称" v-model="newData.companyName"
+                        placeholder="请输入" :rules="[{ message: '', required: true }]" />
+                    <van-field input-align="right" label="注册资本" v-model="newData.registerCapital" placeholder="请输入" />
+                    <van-field input-align="right" class="red-star" v-model="newData.state" is-link readonly
+                        name="picker" label="经营状态" placeholder="请选择" @click="statePricker = true"
+                        :rules="[{ message: '', required: true }]" />
+                    <van-popup v-model:show="statePricker" position="bottom" round>
+                        <van-picker :columns="columns" @confirm="onConfirm" @cancel="cancel" show-toolbar />
+                    </van-popup>
+                    <van-field input-align="right" label="备注" v-model="newData.remark" placeholder="请输入" />
+                </van-form>
+            </view>
+        </view>
+        <view class="container-footer">
+            <van-button @click="closeFn"
+                style="width: 25%; border-radius: 8px; border: 1px solid #1989fa; color: #1989fa;">取消</van-button>
+            <van-button color="#1989fa" @click="submitFn" style="width: 25%; border-radius: 8px;">保存</van-button>
         </view>
     </view>
 </template>
 
 <script>
 import { NEWDATA } from "./data.jsx"
+import { postCompanyBtAddCompany } from "@/api/company"
 export default {
     //import引入的组件需要注入到对象中才能使用
     components: {},
@@ -50,13 +62,36 @@ export default {
         cancel() {
             this.statePricker = false
         },
-        validator(val) {
-           if(val){
-            return true
-           }else{
-            return false;
-           }
-        }
+        // 取消
+        closeFn() {
+            this.newData = { ...NEWDATA }
+        },
+        // 保存
+        submitFn() {
+            // 验证数据
+            if (this.$refs.searchFromRef.validate()) {
+                postCompanyBtAddCompany(this.newData)
+                    .then(res => {
+                        console.log(res)
+                        if (res == "新增成功") {
+                            Toast.success("添加成功")
+                            uni.navigateTo({
+                                url: "/subPages/pages/companyManage/search/list",
+                            })
+                        } else {
+                            Toast.fail(err.msg);
+                        }
+                    })
+                    .catch(err => {
+                        console.log(err)
+                        Toast.fail(err.msg);
+                    })
+                // 验证通过,可以提交数据
+                console.log(this.newData)
+            } else {
+                // 验证不通过,可以做一些提示
+            }
+        },
     },
     //生命周期 - 创建完成(可以访问当前this实例)
     created() {
@@ -81,11 +116,47 @@ export default {
     margin: 10px 0 10px 18px;
     color: #616161;
 }
+
 .red-star {
-  ::v-deep .van-field__label:before {
-    content: '*';
-    color: #ff0000;
-    margin-right: 5px;
-  }
+    ::v-deep .van-field__label:before {
+        content: '*';
+        color: #ff0000;
+        margin-right: 5px;
+    }
+}
+
+.page-container {
+    background-color: #f5f5f5;
+    height: 100%;
+    overflow: hidden;
+    display: flex;
+    flex-direction: column;
+    box-sizing: border-box;
+}
+
+.title {
+    margin: 10px 0;
+}
+
+.container-center {
+    flex: 1;
+    padding: 30rpx;
+    overflow: auto;
+}
+
+.container-footer {
+    height: 100rpx;
+    display: flex;
+    gap: 40px;
+    justify-content: center;
+    align-items: center;
+    padding: 0 30rpx;
+    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.2);
+    /* 只显示上方阴影 */
+
+    ::v-deep .van-button {
+        width: 30%;
+        height: 30px;
+    }
 }
 </style>

+ 0 - 1
src/subPages/pages/companyManage/search/list.vue

@@ -137,7 +137,6 @@ export default {
             uni.navigateTo({
                 url: "/subPages/pages/companyManage/search/com/addCompany",
             })
-            console.log("点击新增")
         },
         // 筛选
         searchFromFn() {