dev01 1 year ago
parent
commit
6ad7aa2a9e

+ 1 - 0
src/app.config.js

@@ -7,6 +7,7 @@ export default {
     'pages/accountfrom/index', // 添加报销数据
     'pages/drafts/index', // 报销提交
     'pages/dataindex/index', // 订单数据索引
+    'pages/companydata/index', // 
     'pages/draftsdetail/index', // 费用详情
     'pages/mergedetail/index', // 合并报销详情
     'pages/debitnote/index', // 借支单列表

+ 3 - 0
src/pages/companydata/index.config.js

@@ -0,0 +1,3 @@
+export default {
+  navigationBarTitleText: '选择企业',
+}

+ 171 - 0
src/pages/companydata/index.jsx

@@ -0,0 +1,171 @@
+import React, { Component } from "react";
+import Taro from "@tarojs/taro";
+import { Text, View } from "@tarojs/components";
+import { AtSearchBar, AtListItem, AtButton, AtIcon } from "taro-ui";
+import { getUserByName, getOrderByUid } from "../../utils/servers/servers";
+import "taro-ui/dist/style/components/search-bar.scss";
+import "taro-ui/dist/style/components/button.scss";
+import "taro-ui/dist/style/components/icon.scss";
+import "taro-ui/dist/style/components/list.scss";
+import "taro-ui/dist/style/components/icon.scss";
+import ListBottomStart from "../../components/common/listBottomStart";
+
+// import "../drafts/index.less";
+
+class CompanyData extends Component {
+  constructor(props) {
+    super(props);
+    this.state = {
+      value: "",
+      list: [],
+      listState: "NO_DATA",
+      pageNo: 1,
+      listVisible: false,
+    };
+    this.onChange = this.onChange.bind(this);
+    this.getList = this.getList.bind(this);
+  }
+
+  componentDidMount() {
+
+  }
+
+  onReachBottom() {
+    this.getList(this.state.value, this.state.pageNo + 1);
+  }
+
+  onChange(value, lv = true) {
+    this.setState({
+      value,
+    });
+    if (value.length < 2 && !lv) {
+      Taro.showToast({ title: "最少输入两个字符", icon: "none" });
+      return;
+    }
+    if (value.length < 4 && lv) {
+      return;
+    }
+    this.getList(value);
+  }
+
+  getList(value = this.state.value, pageNo = 1) {
+    this.setState({
+      listState: "LOADING",
+    });
+    getUserByName({
+      name: value,
+      type: 1,
+      pageNo: pageNo,
+      pageSize: 20,
+    })
+      .then((msg) => {
+        if (msg.error.length === 0) {
+          if (msg.data.totalCount === 0) {
+            this.setState({
+              listState: "NO_DATA",
+            });
+          } else if (
+            msg.data.totalCount === this.state.list.length &&
+            pageNo !== 1
+          ) {
+            Taro.showToast({ title: "没有更多数据了", icon: "none" });
+            this.setState({
+              listState: "NO_MORE_DATA",
+            });
+          } else {
+            if (
+              msg.data.totalCount ===
+              (pageNo === 1
+                ? msg.data.list
+                : this.state.list.concat(msg.data.list)
+              ).length
+            ) {
+              this.setState({
+                listState: "NO_MORE_DATA",
+              });
+            }
+          }
+          this.setState({
+            list:
+              pageNo === 1
+                ? msg.data.list
+                : this.state.list.concat(msg.data.list),
+            pageNo: msg.data.pageNo,
+          });
+        } else {
+          Taro.showToast({ title: msg.error[0].message, icon: "none" });
+          this.setState({
+            listState: msg.error[0].field === "403" ? "NO_DATA" : "RELOAD",
+          });
+        }
+      })
+      .catch(() => {
+        this.setState({
+          listState: "RELOAD",
+        });
+      });
+  }
+
+
+  render() {
+    const { } = this.state
+    return (
+      <>
+        <AtSearchBar
+          placeholder="请输入企业名称"
+          showActionButton
+          value={this.state.value}
+          onChange={this.onChange}
+          onActionClick={() => {
+            this.setState({
+              listVisible: false,
+            });
+            this.onChange(this.state.value, false);
+          }}
+          onConfirm={() => {
+            this.onChange(this.state.value, false);
+          }}
+          onClear={() => {
+            this.setState({
+              value: "",
+              list: [],
+              listState: "NO_DATA",
+              pageNo: 1,
+              listVisible: false,
+            });
+          }}
+        />
+        <View>
+          {!this.state.listVisible &&
+            this.state.list.map((v, k) => (
+              <View key={k}>
+                <AtListItem
+                  title={v.name}
+                  arrow="right"
+                  iconInfo={{ size: 25, color: "#000000", value: "bookmark" }}
+                  onClick={() => {
+                    let pages = Taro.getCurrentPages();
+                    let prevPage = pages[pages.length - 2];
+                    prevPage.setData({
+                      userNames: v.name,
+                    });
+                    Taro.navigateBack({
+                      delta: 1
+                    })
+                  }}
+                />
+              </View>
+            ))}
+          <ListBottomStart
+            state={this.state.listState}
+            reload={() => {
+              this.onChange(this.state.value);
+            }}
+          />
+        </View>
+      </>
+    );
+  }
+}
+
+export default CompanyData;

+ 28 - 10
src/pages/drafts/index.jsx

@@ -96,6 +96,7 @@ class Drafts extends Component {
       debitId: currPage.data.debitId || data.debitId,
       // debitTotalAmount: currPage.data.totalAmount || data.debitTotalAmount || 0,
       debitTotalAmount: currPage.data.totalAmount || data.debitTotalAmount,
+      userNames: currPage.data.userNames || data.userNames, // 公出企业
     }
     this.setState({
       data: { ...this.state.data, ...obj },
@@ -579,16 +580,32 @@ class Drafts extends Component {
       <View className="subform">
         <View className="title">{getAccountName(data.type, data.typeOther)}</View>
         {data.type == 1 &&
-          <View className="inputFormItem">
-            <AtInput
-              name='userNames'
-              title='公出企业:'
-              type='text'
-              placeholder='请填写公出企业'
-              value={data.userNames}
-              onChange={e => { data.userNames = e }}
-            />
-          </View>}
+          // <View className="inputFormItem">
+          //   <AtInput
+          //     name='userNames'
+          //     title='公出企业:'
+          //     type='text'
+          //     placeholder='请填写公出企业'
+          //     value={data.userNames}
+          //     onChange={e => { data.userNames = e }}
+          //   />
+          // </View>
+
+          <View className="formItem">
+            <View className="formName">公出企业:</View>
+            <View className="formValue"
+              onClick={() => {
+                Taro.navigateTo({
+                  url: "/pages/companydata/index"
+                })
+              }}>
+              <View>
+                <View>{data.userNames}</View>
+              </View>
+              <AtIcon value="chevron-right" size="20" color="#000000" />
+            </View>
+          </View>
+        }
         {data.type == 1 &&
           <View className="inputFormItem">
             <AtInput
@@ -828,6 +845,7 @@ class Drafts extends Component {
             <AtIcon value="chevron-right" size="20" color="#000000" />
           </View>
         </View>
+        < View className="tips">注:不填写则默认报销至部门</View>
         {
           this.state.visible != "" &&
           <NewModal

+ 2 - 2
src/pages/mergedetail/index.jsx

@@ -473,8 +473,8 @@ class Drafts extends Component {
                   })
                 }}
                 height={75}
-                maxLength={50}
-                placeholder={(data.type == 4 || data.type == 5) ? "请填写说明:" : "请填写报销事由"}
+                maxLength={10}
+                placeholder="最多10个字,简述事由"
               />
             </View> :
             <View className="formValueremarks">{data.remarks}</View>}