Browse Source

采购管理 回款打款管理

hml2020 1 year ago
parent
commit
2684d4b2d0

+ 52 - 0
src/api/procure.ts

@@ -0,0 +1,52 @@
+/*
+ * @Author: weisheng
+ * @Date: 2023-04-17 12:51:22
+ * @LastEditTime: 2023-04-20 15:01:53
+ * @LastEditors: weisheng
+ * @Description:
+ * @FilePath: \uniapp-vue3-fant-ts\src\api\DemoApi.ts
+ * 记得注释
+ */
+import http from '@/http/HttpClient';
+import BaseResponse from '@/model/BaseResponse';
+import Chanel from '@/model/Chanel';
+import UserInfo from '@/model/UserInfo';
+// 这里将API方法统一管理
+export default class DemoApi {
+  // 采购管理  表单配置信息
+  static getConfig(data): Promise<BaseResponse<Chanel[]>> {
+    return http.server().get('visual-api/paas/visualdev/OnlineDev/' + data + '/Config')
+      .then((res) => {
+        return res;
+      });
+  }
+
+  // 采购管理-项目列表
+  static getProjectList(): Promise<BaseResponse<Chanel[]>> {
+    return http.server().get('bi-api/report/dataapi/project_info').then((res) => {
+        return res;
+      });
+  }
+
+  // 采购管理-表单数据列表
+  static getFormList(data): Promise<BaseResponse<Chanel[]>> {
+    return http.server().post('bi-api/cube/browser/'+ data.dbLinkId,data.form).then((res) => {
+        return res.data;
+      });
+  }
+ //编辑数据
+  static editData(data): Promise<BaseResponse<Chanel[]>> {
+    return http
+      .server()
+      .put(
+        'visual-api/paas/visualdev/OnlineDev/v2/' +
+          data.formKey +
+          '/' +
+          data.id,
+        data.data
+      )
+      .then((res) => {
+        return res.data;
+      })
+  }
+}

+ 28 - 1
src/pages.json

@@ -80,7 +80,20 @@
         "navigationBarTitleText": "司机加油记录"
       }
     },
-
+    {
+      "path": "pages/procure/list",
+      "style": {
+        "navigationStyle": "default",
+        "navigationBarTitleText": "采购管理"
+      }
+    },
+    {
+      "path": "pages/procure/edit",
+      "style": {
+        "navigationStyle": "default",
+        "navigationBarTitleText": "采购管理"
+      }
+    },
     {
       "path": "pages/settlement/list",
       "style": {
@@ -109,6 +122,20 @@
         "navigationBarTitleText": "油品信息管理"
       }
     }
+    {
+      "path": "pages/payment/list",
+      "style": {
+        "navigationStyle": "default",
+        "navigationBarTitleText": "回款打款管理"
+      }
+    },
+    {
+      "path": "pages/payment/edit",
+      "style": {
+        "navigationStyle": "default",
+        "navigationBarTitleText": "回款打款管理"
+      }
+    }
   ],
   "tabBar": {
     "custom": true,

+ 3 - 3
src/pages/home/Home.vue

@@ -14,9 +14,9 @@
       <view class="main">
         <wd-cell-group border>
           <template>
-            <wd-cell title="采购管理" is-link icon="edit" to="/pages/publish/Publish" />
+            <wd-cell title="采购管理" is-link icon="edit" to="/pages/procure/list" />
             <wd-cell title="结算管理" is-link icon="spool" to="/pages/settlement/list" />
-            <wd-cell title="回款打款管理" is-link icon="spool" to="/pages/home/history" />
+            <wd-cell title="回款打款管理" is-link icon="spool" to="/pages/payment/list" />
             <wd-cell title="油品信息管理" is-link icon="location" to="/pages/oils/list" />
           </template>
         </wd-cell-group>
@@ -70,7 +70,7 @@ function doLogout() {
     })
     .catch((error) => {
       console.log(error);
-    })
+    });
 }
 </script>
 

+ 9 - 9
src/pages/login/Login.vue

@@ -53,9 +53,9 @@
             class="text-center"
             @click="openPrivacyContract"
           >
-            <wd-checkbox :model-value="isAuth" shape="square">
+            <!-- <wd-checkbox :model-value="isAuth" shape="square">
               <text style="color: #333">《用户隐私保护指引》</text>
-            </wd-checkbox>
+            </wd-checkbox> -->
           </view>
         </view>
       </view>
@@ -79,7 +79,7 @@ const router = useRouter(); // 路由
 // 登录按钮是否禁用
 const disabled = computed(() => {
   return !username.value || !name.value || !code.value;
-})
+});
 // 验证码图片地址
 const codeSrc = ref<string>(
   'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
@@ -104,10 +104,10 @@ getCode();
 
 // 登录接口
 async function doLogin() {
-  if (!isAuth.value) {
-    toast.error('请先阅读《用户隐私保护指引》');
-    return
-  }
+  // if (!isAuth.value) {
+  //   toast.error('请先阅读《用户隐私保护指引》');
+  //   return
+  // }
   toast.loading({ loadingType: 'ring', msg: '登录中' });
   uni.request({
     url: `https://miniapp.zhangmushiye.com/api/blade-auth/oauth/token?password=${md(
@@ -129,7 +129,7 @@ async function doLogin() {
         toast.close();
         toast.error(res.data.error_description);
         getCode();
-        return
+        return;
       }
       if (res.data.access_token) {
         toast.close();
@@ -157,7 +157,7 @@ const openPrivacyContract = () => {
       isAuth.value = false;
     },
   });
-}
+};
 </script>
 
 <style lang="scss" scoped>

+ 38 - 38
src/pages/oils/list.vue

@@ -25,7 +25,7 @@
       @close="close"
       @select="select"
     />
-
+
     <template v-for="(item, index) in settlementList" :key="index">
       <wd-card :title="'项目编号:' + item.COL_0.value">
         <view class="justify-between items-center flex">
@@ -94,11 +94,11 @@ function changeSearchType({ item, index }) {
     actions.value = oilList.value;
   } else if (index === 2) {
     actions.value = userList.value;
-  }
+  }
 }
 function searchFocus() {
   showSheet.value = true;
-}
+}
 function searchChange(value) {
   // 如果输入框为空则清空 searchForm
   if (!value.value) {
@@ -108,25 +108,25 @@ function searchChange(value) {
       customerName: '',
     };
     getSettlementList();
-  }
+  }
 }
 // cancelChange
 function cancelChange(value) {
   getSettlementList();
-}
+}
 const actions = ref([]);
-// 油品名称
+// 油品名称
 const oilList = ref([{ name: '柴油' }, { name: '汽油' }]);
-// 客户名称
+// 客户名称
 const userList = ref([]);
-// 获取客户列表
+// 获取客户列表
 const getUserList = () => {
   DemoApi.getCustomerList().then((res) => {
     userList.value = res.data.map((item) => {
       return { name: item.COL_ALIAS_1 };
-    })
+    });
   });
-}
+};
 getUserList();
 const projectList = ref([]);
 const getProjectList = () => {
@@ -134,22 +134,22 @@ const getProjectList = () => {
   DemoApi.getProjectNameList().then((res) => {
     projectList.value = res.data.map((item) => {
       return { name: item.项目名称 };
-    })
+    });
     actions.value = projectList.value;
-  })
-};
+  });
+};
 getProjectList();
-
+
 function close() {
   showSheet.value = false;
-}
+}
 const searchForm = ref({
   projectName: '',
   oilName: '',
   customerName: '',
 });
 const toast = useToast();
-
+
 function select({ item, index }) {
   showSheet.value = false;
   if (searchType.value === '项目名称') {
@@ -158,9 +158,9 @@ function select({ item, index }) {
     searchForm.value.oilName = item.name;
   } else if (searchType.value === '客户名称') {
     searchForm.value.customerName = item.name;
-  }
+  }
   value.value = item.name;
-}
+}
 // 分页数据
 const pageQuery = ref({
   current: 1,
@@ -168,8 +168,8 @@ const pageQuery = ref({
   descs: 536,
   total: 0,
 });
-
-// 获取结算管理列表
+
+// 获取结算管理列表
 const formKey = ref<string>('a6decb955c72427dedf7db22a4142934');
 const idKeyData = ref<string>('');
 const settlementList = ref([]);
@@ -179,14 +179,14 @@ const getSettlementList = () => {
     const { dbLinkId, idKey } = res.data;
     idKeyData.value = idKey;
     tableData.value = JSON.parse(res.data.tables || '[]');
-    // 匹配fieldName == menu name的值 并且再menu添加 fieldId
+    // 匹配fieldName == menu name的值 并且再menu添加 fieldId
     menu.value.map((item) => {
       tableData.value.map((table) => {
         if (table.fieldName === item.content) {
           item.fieldId = table.fieldId;
-        }
+        }
       });
-    })
+    });
     const params = {
       dbLinkId,
       pageQuery: pageQuery.value,
@@ -201,19 +201,19 @@ const getSettlementList = () => {
       };
       if (searchForm.value[item.filedName]) {
         obj.values.push(searchForm.value[item.filedName]);
-      }
+      }
       params.paramList.push(obj);
-    })
+    });
 
     DemoApi.getFormDataList(params).then((resp) => {
       const { columnDict, pageData } = resp.data;
       pageQuery.value.total = pageData.total;
       pageQuery.value.current = pageData.current;
       pageQuery.value.size = pageData.size;
-      // columnDict 是 pageData.records 和 tableData 的映射关系
-      // columnDict的key是tableData的fieldId,value是pageData.records的 key
-      // pageData.records 是后台返回的数据
-      // tableData 是前台配置的表头
+      // columnDict 是 pageData.records 和 tableData 的映射关系
+      // columnDict的key是tableData的fieldId,value是pageData.records的 key
+      // pageData.records 是后台返回的数据
+      // tableData 是前台配置的表头
       const idKey = columnDict[idKeyData.value];
       const arr = [];
       pageData.records.map((val) => {
@@ -230,28 +230,28 @@ const getSettlementList = () => {
                 fieldId: item.fieldId,
                 pageDataRecordKey: columnDict[key],
               };
-            }
+            }
           });
-        }
+        }
         arr.push(obj);
-      })
-      // 回到顶部
+      });
+      // 回到顶部
       settlementList.value = arr;
-    })
+    });
   });
-}
+};
 getSettlementList();
 function handleChangePagination() {
   getSettlementList();
-}
+}
 function goEdit(item) {
   router.push({
     path: 'pages/oils/form',
     query: { filedsData: JSON.stringify(item || '[]'), formKey: formKey.value },
   });
-}
+}
 </script>
-
+
 <style lang="scss" scoped>
 .search-type {
   position: relative;

+ 173 - 0
src/pages/payment/edit.vue

@@ -0,0 +1,173 @@
+<template>
+  <view class="edit">
+    <wd-cell-group custom-class="group" border>
+      <wd-calendar
+        v-model="detail['收款日期']"
+        label="收款日期"
+        @confirm="handleConfirm($event, 1)"
+      />
+      <wd-picker :columns="columns" label="项目名称" v-model="detail['项目名称']" />
+      <wd-input type="number" label="金额" v-model="detail['金额']" />
+      <wd-picker :columns="payList" label="回款方式" v-model="detail['回款方式']" />
+      <wd-input type="number" label="贴息费" v-model="detail['贴息费']" />
+      <wd-input type="number" label="净额" v-model="detail['净额']" />
+      <wd-input type="number" label="余额" v-model="detail['余额']" />
+      <wd-input label="汇款单位名称" v-model="detail['汇款单位名称']" />
+      <wd-input label="汇款单位账号" v-model="detail['汇款单位账号']" />
+      <wd-input label="账户名称" v-model="detail['账户名称']" />
+      <wd-input label="收款银行账号" readonly v-model="detail['收款银行账号']" />
+      <wd-cell title="汇款类型">
+        <template #default>
+          <wd-radio-group v-model="detail['汇款类型']" shape="button">
+            <wd-radio :value="'打款'">打款</wd-radio>
+            <wd-radio :value="'回款'">回款</wd-radio>
+          </wd-radio-group>
+        </template>
+      </wd-cell>
+      <wd-input label="财务姓名" v-model="detail['财务姓名']" />
+      <!-- <wd-input label="采购单名称" v-model="detail['采购单名称']" />
+      <wd-input label="采购单号" v-model="detail['采购单号']" />
+      <wd-calendar
+        v-model="detail['提交日期']"
+        label="提交日期"
+        @confirm="handleConfirm($event, 1)"
+      />
+      <wd-input type="number" label="采购单价(元)" v-model="detail['采购单价(元)']" />
+      <wd-input type="number" label="采购金额(元)" v-model="detail['采购金额(元)']" />
+      <wd-input label="采购人" v-model="detail['采购人']" />
+      <wd-input label="采购名称" v-model="detail['采购名称']" />
+      <wd-input
+        :label="'采购数量(' + detail['单位吨或者升'] + ')'"
+        v-model="detail['采购数量(吨)']"
+      />
+      <wd-cell title="单位吨或者升">
+        <template #default>
+          <wd-radio-group v-model="detail['单位吨或者升']" shape="button">
+            <wd-radio :value="'吨'">吨</wd-radio>
+            <wd-radio :value="'升'">升</wd-radio>
+          </wd-radio-group>
+        </template>
+      </wd-cell>
+      <wd-input label="油品名称" v-model="detail['油品名称']" />
+      <wd-input label="型号" v-model="detail['型号']" />
+      <wd-input label="市场价" v-model="detail['市场价']" />
+      <wd-input label="销售价格" v-model="detail['销售价格']" />
+      <wd-input label="折吨价" v-model="detail['折吨价']" />
+      <wd-input label="下浮价" v-model="detail['下浮价']" />
+      <wd-input label="价差" v-model="detail['价差']" />
+      <wd-input label="付款名称" v-model="detail['付款名称']" />
+      <wd-calendar
+        v-model="detail['付款日期']"
+        label="付款日期"
+        @confirm="handleConfirm($event, 2)"
+      />
+      <wd-input label="收款名称" v-model="detail['收款名称']" />
+      <wd-picker :columns="columns" label="项目名称" v-model="detail['项目名称']" />
+      <wd-input label="项目编号" v-model="detail['项目编号']" /> -->
+      <view class="btn">
+        <wd-button block type="primary" @click="formSubmit">提交</wd-button>
+      </view>
+    </wd-cell-group>
+  </view>
+</template>
+<script setup>
+import { onLoad } from '@dcloudio/uni-app';
+import dataService from '@/api/procure';
+import { defineProps, ref, toRefs } from 'vue';
+import moment from 'moment';
+const props = defineProps({
+  id: {
+    type: String,
+    default: '',
+  },
+});
+const detail = ref({});
+const columns = ref([]);
+const payList = ref([
+  '银行转账',
+  '微信',
+  '商业兑换',
+  '银行承兑',
+  '铁建银信',
+  '云信',
+  'E信通',
+  '简单汇',
+]);
+const formId = ref('');
+const oldValues = ref({});
+const { id } = toRefs(props);
+onLoad((options) => {
+  const item = JSON.parse(options.item);
+  formId.value = options.formId;
+  const obj = {};
+  item.forEach((child) => {
+    obj[child.text] = child.value;
+  });
+  detail.value = obj;
+  console.log(detail.value);
+  oldValues.value = JSON.parse(options.item);
+  // console.log(oldValues.value);
+  projectList();
+});
+
+// 获取采购管理-项目列表
+function projectList() {
+  dataService.getProjectList().then((res) => {
+    if (res.data.code === 200) {
+      columns.value = res.data.data.map((child) => child['项目名称']);
+    } else {
+      columns.value = [];
+    }
+  });
+}
+
+function handleConfirm(e, num) {
+  if (num === 1) {
+    detail.value['收款日期'] = moment(e.value).format('YYYY-MM-DD');
+  } else {
+    detail.value['付款日期'] = moment(e.value).format('YYYY-MM-DD');
+  }
+}
+function formSubmit() {
+  const old = {};
+  const dataObj = {};
+  oldValues.value.forEach((child) => {
+    old[child.valueKey] = child.value;
+    for (const key in detail.value) {
+      if (child.text === key) {
+        dataObj[child.valueKey] = detail.value[key];
+      }
+    }
+  });
+  const data = [
+    {
+      data: JSON.stringify(dataObj),
+      id: detail.value.idKey,
+      oldData: JSON.stringify(old),
+    },
+  ];
+  const params = {
+    formKey: formId.value,
+    id: detail.value.idKey,
+    data: data,
+  };
+  dataService.editData(params).then((res) => {
+    if (res.code === 200) {
+      toast.success('更新成功');
+      uni.navigateBack({
+        delta: 1,
+      });
+    } else {
+      toast.error('提交失败');
+    }
+  });
+}
+</script>
+<style lang="scss" scoped>
+.edit {
+  padding-bottom: 15px;
+  .btn {
+    padding: 20px 10px;
+  }
+}
+</style>

+ 307 - 0
src/pages/payment/list.vue

@@ -0,0 +1,307 @@
+<template>
+  <view class="list">
+    <view class="search">
+      <wd-search
+        ref="search"
+        v-model="value"
+        cancel-txt="搜索"
+        @cancel="onSearch"
+        :disabled="searchType === '项目名称'"
+      >
+        <template #prefix>
+          <wd-popover v-model="show" mode="menu" :content="menu" @menuclick="changeSearchType">
+            <view class="search-type">
+              <text>{{ searchType }}</text>
+              <wd-icon custom-class="icon-arrow" name="fill-arrow-down"></wd-icon>
+            </view>
+          </wd-popover>
+        </template>
+      </wd-search>
+    </view>
+    <view style="height: 70px"></view>
+    <view v-if="listData.length > 0">
+      <wd-card v-for="(item, index) in oldData" :key="index">
+        <view v-for="(child, childIndex) in item" :key="childIndex">
+          <view class="flex">
+            <view class="left">{{ child.text }}:</view>
+            <view class="right">{{ child.value }}</view>
+          </view>
+        </view>
+        <template #footer>
+          <wd-button size="small" plain @click="editClick(item)">编辑</wd-button>
+        </template>
+      </wd-card>
+      <wd-loadmore custom-class="loadmore" :state="loadState" />
+    </view>
+    <view v-else>
+      <wd-loadmore custom-class="loadmore" state="finished" />
+    </view>
+  </view>
+  <wd-action-sheet
+    v-model="sheetShow"
+    :actions="columns"
+    title="项目名称"
+    @close="close"
+    @select="onSelect"
+    cancel-text="取消"
+  ></wd-action-sheet>
+</template>
+<script setup>
+import { onLoad, onReachBottom } from '@dcloudio/uni-app';
+import dataService from '@/api/procure';
+import { ref, onMounted } from 'vue';
+const value = ref('');
+const searchType = ref('汇款单位名称');
+const loadState = ref('loading');
+const columns = ref([]);
+const show = ref(false);
+const sheetShow = ref(false);
+const menu = ref([
+  {
+    content: '汇款单位名称',
+    value: 2,
+  },
+  {
+    content: '项目名称',
+    value: 3,
+  },
+]);
+const listData = ref([]);
+const dbLinkId = ref('');
+const tableColumns = ref([]);
+const isMore = ref(true);
+const idKey = ref('');
+const form = ref({
+  pageQuery: {
+    current: 1,
+    size: 20,
+  },
+  paramList: [
+    {
+      cubeColumnId: 875,
+      function: 'like',
+      values: [],
+    },
+  ],
+});
+const oldData = ref([]);
+const formData = ref([]);
+
+onLoad((options) => {
+  projectList();
+  getFormConfig();
+});
+
+onReachBottom(() => {
+  if (isMore.value) {
+    form.value.pageQuery.current++;
+    getFormList();
+  }
+});
+
+// 获取采购管理-项目列表
+function projectList() {
+  dataService.getProjectList().then((res) => {
+    if (res.data.code === 200) {
+      columns.value = res.data.data.map((item) => {
+        return {
+          name: item['项目名称'],
+        };
+      });
+    } else {
+      columns.value = [];
+    }
+  });
+}
+
+// 获取表单配置信息
+function getFormConfig() {
+  dataService.getConfig('9317b42e0d9a4a54706a5fcf9ab05158').then((res) => {
+    const { code, data } = res.data;
+    if (code === 200) {
+      idKey.value = String(data.idKey);
+      formData.value = JSON.parse(data.formData);
+      dbLinkId.value = data.dbLinkId;
+      tableColumns.value = JSON.parse(data.tables);
+      getFormList();
+    }
+  });
+}
+
+function editClick(item) {
+  uni.navigateTo({
+    url:
+      '/pages/payment/edit?item=' +
+      JSON.stringify(item) +
+      '&formId=9317b42e0d9a4a54706a5fcf9ab05158',
+  });
+}
+
+// 搜索
+function onSearch() {
+  oldData.value = [];
+  form.value.pageQuery.current = 1;
+  isMore.value = true;
+  getFormList();
+}
+
+// 获取列表信息
+function getFormList() {
+  if (searchType.value !== '项目名称') {
+    form.value.paramList[0].values = [value.value];
+  }
+  const params = {
+    dbLinkId: dbLinkId.value,
+    form: form.value,
+  };
+  dataService.getFormList(params).then((res) => {
+    if (res.code === 200) {
+      const { columnDict, pageData } = res.data;
+      if (pageData.records.length < 20 || pageData.records.length == 0) {
+        loadState.value = 'finished';
+        isMore.value = false;
+      } else {
+        isMore.value = true;
+        loadState.value = 'loading';
+      }
+      const arr = tableColumns.value.map((val) => {
+        for (const key in columnDict) {
+          if (val.fieldId == key) {
+            val.filedCode = columnDict[key];
+          } else {
+            const obj = {
+              filedCode: columnDict[key],
+              fieldName: 'idKey',
+            };
+          }
+          val.valueKey = key;
+        }
+        return val;
+      });
+      arr.push({
+        filedCode: columnDict[idKey.value],
+        fieldName: 'idKey',
+        valueKey: idKey.value,
+        fieldId: idKey.value,
+      });
+      listData.value = pageData.records.map((val) => {
+        const newObj = [];
+        for (const k in val) {
+          arr.forEach((v) => {
+            const obj = {};
+            if (v.filedCode == k) {
+              newObj.push({
+                text: v.fieldName,
+                value: val[k],
+                valueKey: v.fieldId,
+              });
+              // newObj[v.fieldName] = val[k];
+            }
+          });
+        }
+        return newObj;
+      });
+      if (form.value.pageQuery.current > 1) {
+        listData.value.forEach((item) => {
+          oldData.value.push(item);
+        });
+      } else {
+        oldData.value = listData.value;
+      }
+    }
+  });
+}
+
+function changeSearchType(e) {
+  oldData.value = [];
+  searchType.value = e.item.content;
+  form.value.pageQuery.current = 1;
+  isMore.value = true;
+  if (e.item.value === 3) {
+    sheetShow.value = true;
+  } else {
+    form.value.paramList = [
+      {
+        cubeColumnId: 558,
+        function: 'like',
+        values: [],
+      },
+    ];
+  }
+}
+
+function onSelect({ item, rowIndex, colIndex }) {
+  form.value.paramList = [
+    {
+      cubeColumnId: 561,
+      function: 'in',
+      values: [item.name],
+    },
+  ];
+  getFormList();
+}
+// 关闭项目选项
+function close() {
+  searchType.value = '采购单号';
+  sheetShow.value = false;
+  value.value = '';
+  oldData.value = [];
+  form.value.pageQuery.current = 1;
+}
+</script>
+
+<style lang="scss" scoped>
+.list {
+  min-height: calc(100vh - var(--window-top) - var(--window-bottom));
+  width: 100vw;
+  box-sizing: border-box;
+  background: #f1f1f1;
+  position: relative;
+  // padding: 0 15px;
+  // box-sizing: border-box;
+  // background-image: url('https://pic.imgdb.cn/item/65796604c458853aef1aec2a.jpg');
+  // background-size: 100% 100%;
+  .search {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100%;
+    .search-type {
+      position: relative;
+      height: 30px;
+      line-height: 30px;
+      padding: 0 8px 0 16px;
+    }
+    .search-type::after {
+      position: absolute;
+      content: '';
+      width: 1px;
+      right: 0;
+      top: 5px;
+      bottom: 5px;
+      background: rgba(0, 0, 0, 0.25);
+    }
+    .search-type {
+      :deep(.icon-arrow) {
+        display: inline-block;
+        font-size: 20px;
+        vertical-align: middle;
+      }
+    }
+  }
+
+  .flex {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    .left {
+      width: 30%;
+      margin-right: 10px;
+    }
+    .right {
+      flex: 1;
+      text-align: right;
+    }
+  }
+}
+</style>

+ 138 - 0
src/pages/procure/edit.vue

@@ -0,0 +1,138 @@
+<template>
+  <view class="edit">
+    <wd-cell-group custom-class="group" :title="'采购单:' + detail['采购单名称']" border>
+      <wd-input label="采购单名称" v-model="detail['采购单名称']" />
+      <wd-input label="采购单号" v-model="detail['采购单号']" />
+      <wd-calendar
+        v-model="detail['提交日期']"
+        label="提交日期"
+        @confirm="handleConfirm($event, 1)"
+      />
+      <wd-input type="number" label="采购单价(元)" v-model="detail['采购单价(元)']" />
+      <wd-input type="number" label="采购金额(元)" v-model="detail['采购金额(元)']" />
+      <wd-input label="采购人" v-model="detail['采购人']" />
+      <wd-input label="采购名称" v-model="detail['采购名称']" />
+      <wd-input
+        :label="'采购数量(' + detail['单位吨或者升'] + ')'"
+        v-model="detail['采购数量(吨)']"
+      />
+      <wd-cell title="单位吨或者升">
+        <template #default>
+          <wd-radio-group v-model="detail['单位吨或者升']" shape="button">
+            <wd-radio :value="'吨'">吨</wd-radio>
+            <wd-radio :value="'升'">升</wd-radio>
+          </wd-radio-group>
+        </template>
+      </wd-cell>
+      <wd-input label="油品名称" v-model="detail['油品名称']" />
+      <wd-input label="型号" v-model="detail['型号']" />
+      <wd-input label="市场价" v-model="detail['市场价']" />
+      <wd-input label="销售价格" v-model="detail['销售价格']" />
+      <wd-input label="折吨价" v-model="detail['折吨价']" />
+      <wd-input label="下浮价" v-model="detail['下浮价']" />
+      <wd-input label="价差" v-model="detail['价差']" />
+      <wd-input label="付款名称" v-model="detail['付款名称']" />
+      <wd-calendar
+        v-model="detail['付款日期']"
+        label="付款日期"
+        @confirm="handleConfirm($event, 2)"
+      />
+      <wd-input label="收款名称" v-model="detail['收款名称']" />
+      <wd-picker :columns="columns" label="项目名称" v-model="detail['项目名称']" />
+      <wd-input label="项目编号" v-model="detail['项目编号']" />
+      <view class="btn">
+        <wd-button block type="primary" @click="formSubmit">提交</wd-button>
+      </view>
+    </wd-cell-group>
+  </view>
+</template>
+<script setup>
+import { onLoad } from '@dcloudio/uni-app';
+import dataService from '@/api/procure';
+import { defineProps, ref, toRefs } from 'vue';
+import moment from 'moment';
+const props = defineProps({
+  id: {
+    type: String,
+    default: '',
+  },
+});
+const detail = ref({});
+const columns = ref([]);
+const formId = ref('');
+const oldValues = ref({});
+const { id } = toRefs(props);
+onLoad((options) => {
+  const item = JSON.parse(options.item);
+  formId.value = options.formId;
+  const obj = {};
+  item.forEach((child) => {
+    obj[child.text] = child.value;
+  });
+  detail.value = obj;
+  oldValues.value = JSON.parse(options.item);
+  // console.log(oldValues.value);
+  projectList();
+});
+
+// 获取采购管理-项目列表
+function projectList() {
+  dataService.getProjectList().then((res) => {
+    if (res.data.code === 200) {
+      columns.value = res.data.data.map((child) => child['项目名称']);
+    } else {
+      columns.value = [];
+    }
+  });
+}
+
+function handleConfirm(e, num) {
+  if (num === 1) {
+    detail.value['提交日期'] = moment(e.value).format('YYYY-MM-DD');
+  } else {
+    detail.value['付款日期'] = moment(e.value).format('YYYY-MM-DD');
+  }
+}
+function formSubmit() {
+  const old = {};
+  const dataObj = {};
+  oldValues.value.forEach((child) => {
+    old[child.valueKey] = child.value;
+    for (const key in detail.value) {
+      if (child.text === key) {
+        dataObj[child.valueKey] = detail.value[key];
+      }
+    }
+  });
+  const data = [
+    {
+      data: JSON.stringify(dataObj),
+      id: detail.value.idKey,
+      oldData: JSON.stringify(old),
+    },
+  ];
+  const params = {
+    formKey: formId.value,
+    id: detail.value.idKey,
+    data: data,
+  };
+  dataService.editData(params).then((res) => {
+    if (res.code === 200) {
+      toast.success('更新成功');
+      uni.navigateBack({
+        delta: 1,
+      });
+    } else {
+      toast.error('提交失败');
+    }
+  });
+}
+</script>
+<style lang="scss" scoped>
+.edit {
+  padding-bottom: 15px;
+  .btn {
+    padding: 20px 10px;
+  }
+}
+</style>

+ 347 - 0
src/pages/procure/list.vue

@@ -0,0 +1,347 @@
+<template>
+  <view class="list">
+    <view class="search">
+      <wd-search
+        ref="search"
+        v-model="value"
+        cancel-txt="搜索"
+        @cancel="onSearch"
+        :disabled="searchType === '项目名称'"
+      >
+        <template #prefix>
+          <wd-popover v-model="show" mode="menu" :content="menu" @menuclick="changeSearchType">
+            <view class="search-type">
+              <text>{{ searchType }}</text>
+              <wd-icon custom-class="icon-arrow" name="fill-arrow-down"></wd-icon>
+            </view>
+          </wd-popover>
+        </template>
+      </wd-search>
+    </view>
+    <view style="height: 70px"></view>
+    <view v-if="listData.length > 0">
+      <wd-card v-for="(item, index) in oldData" :key="index">
+        <view v-for="(child, childIndex) in item" :key="childIndex">
+          <view class="flex">
+            <view class="left">{{ child.text }}:</view>
+            <view class="right">{{ child.value }}</view>
+          </view>
+        </view>
+        <!-- <view class="flex">
+            <view>采购数量:</view>
+            <view>
+              {{ item['采购数量(吨)'] ? item['采购数量(吨)'] : item['采购数量(升)'] }}
+              {{ item['单位吨或者升'] }}
+            </view>
+          </view>
+          <view class="flex">
+            <view>采购金额(元):</view>
+            <view>{{ item['采购金额(元)'] }}</view>
+          </view>
+          <view class="flex">
+            <view>采购单号:</view>
+            <view>{{ item['采购单号'] }}</view>
+          </view>
+          <view class="flex">
+            <view>项目名称:</view>
+            <view>{{ item['项目名称'] }}</view>
+          </view>
+          <view class="flex">
+            <view>价差:</view>
+            <view>{{ item['价差'] }}</view>
+          </view>
+          <view class="flex">
+            <view>销售价格:</view>
+            <view>{{ item['销售价格'] }}</view>
+          </view> -->
+        <template #footer>
+          <wd-button size="small" plain @click="editClick(item)">编辑</wd-button>
+        </template>
+      </wd-card>
+      <wd-loadmore custom-class="loadmore" :state="loadState" />
+    </view>
+    <view v-else>
+      <wd-loadmore custom-class="loadmore" state="finished" />
+    </view>
+  </view>
+  <wd-action-sheet
+    v-model="sheetShow"
+    :actions="columns"
+    title="项目名称"
+    @close="close"
+    @select="onSelect"
+    cancel-text="取消"
+  ></wd-action-sheet>
+</template>
+<script setup>
+import { onLoad, onReachBottom } from '@dcloudio/uni-app';
+import dataService from '@/api/procure';
+import { ref, onMounted } from 'vue';
+const value = ref('');
+const searchType = ref('采购单号');
+const loadState = ref('loading');
+const columns = ref([]);
+const show = ref(false);
+const sheetShow = ref(false);
+const menu = ref([
+  {
+    content: '采购单号',
+    value: 1,
+  },
+  {
+    content: '采购单名称',
+    value: 2,
+  },
+  {
+    content: '项目名称',
+    value: 3,
+  },
+]);
+const listData = ref([]);
+const dbLinkId = ref('');
+const tableColumns = ref([]);
+const isMore = ref(true);
+const idKey = ref('');
+const form = ref({
+  pageQuery: {
+    current: 1,
+    size: 20,
+  },
+  paramList: [
+    {
+      cubeColumnId: 875,
+      function: 'like',
+      values: [],
+    },
+  ],
+});
+const oldData = ref([]);
+const formData = ref([]);
+
+onLoad((options) => {
+  projectList();
+  getFormConfig();
+});
+
+onReachBottom(() => {
+  if (isMore.value) {
+    form.value.pageQuery.current++;
+    getFormList();
+  }
+});
+
+// 获取采购管理-项目列表
+function projectList() {
+  dataService.getProjectList().then((res) => {
+    if (res.data.code === 200) {
+      columns.value = res.data.data.map((item) => {
+        return {
+          name: item['项目名称'],
+        };
+      });
+    } else {
+      columns.value = [];
+    }
+  });
+}
+
+// 获取表单配置信息
+function getFormConfig() {
+  dataService.getConfig('f7436dcb6bbd469b1d154511ab74dd0f').then((res) => {
+    const { code, data } = res.data;
+    if (code === 200) {
+      idKey.value = String(data.idKey);
+      formData.value = JSON.parse(data.formData);
+      dbLinkId.value = data.dbLinkId;
+      tableColumns.value = JSON.parse(data.tables);
+      getFormList();
+    }
+  });
+}
+
+function editClick(item) {
+  uni.navigateTo({
+    url:
+      '/pages/procure/edit?item=' +
+      JSON.stringify(item) +
+      '&formId=f7436dcb6bbd469b1d154511ab74dd0f',
+  });
+}
+
+// 搜索
+function onSearch() {
+  oldData.value = [];
+  form.value.pageQuery.current = 1;
+  isMore.value = true;
+  getFormList();
+}
+
+// 获取列表信息
+function getFormList() {
+  if (searchType.value !== '项目名称') {
+    form.value.paramList[0].values = [value.value];
+  }
+  const params = {
+    dbLinkId: dbLinkId.value,
+    form: form.value,
+  };
+  dataService.getFormList(params).then((res) => {
+    if (res.code === 200) {
+      const { columnDict, pageData } = res.data;
+      if (pageData.records.length < 20 || pageData.records.length == 0) {
+        loadState.value = 'finished';
+        isMore.value = false;
+      } else {
+        isMore.value = true;
+        loadState.value = 'loading';
+      }
+      const arr = tableColumns.value.map((val) => {
+        for (const key in columnDict) {
+          if (val.fieldId == key) {
+            val.filedCode = columnDict[key];
+          } else {
+            const obj = {
+              filedCode: columnDict[key],
+              fieldName: 'idKey',
+            };
+          }
+          val.valueKey = key;
+        }
+        return val;
+      });
+      arr.push({
+        filedCode: columnDict[idKey.value],
+        fieldName: 'idKey',
+        valueKey: idKey.value,
+        fieldId: idKey.value,
+      });
+      listData.value = pageData.records.map((val) => {
+        const newObj = [];
+        for (const k in val) {
+          arr.forEach((v) => {
+            const obj = {};
+            if (v.filedCode == k) {
+              newObj.push({
+                text: v.fieldName,
+                value: val[k],
+                valueKey: v.fieldId,
+              });
+              // newObj[v.fieldName] = val[k];
+            }
+          });
+        }
+        return newObj;
+      });
+      if (form.value.pageQuery.current > 1) {
+        listData.value.forEach((item) => {
+          oldData.value.push(item);
+        });
+      } else {
+        oldData.value = listData.value;
+      }
+    }
+  });
+}
+
+function changeSearchType(e) {
+  // oldData.value = [];
+  searchType.value = e.item.content;
+  form.value.pageQuery.current = 1;
+  isMore.value = true;
+  if (e.item.value === 3) {
+    sheetShow.value = true;
+  } else if (e.item.value === 1) {
+    form.value.paramList = [
+      {
+        cubeColumnId: 875,
+        function: 'like',
+        values: [],
+      },
+    ];
+  } else {
+    form.value.paramList = [
+      {
+        cubeColumnId: 572,
+        function: 'like',
+        values: [],
+      },
+    ];
+  }
+}
+
+function onSelect({ item, rowIndex, colIndex }) {
+  form.value.paramList = [
+    {
+      cubeColumnId: 572,
+      function: 'in',
+      values: [item.name],
+    },
+  ];
+  getFormList();
+}
+// 关闭项目选项
+function close() {
+  searchType.value = '采购单号';
+  sheetShow.value = false;
+  value.value = '';
+  oldData.value = [];
+  form.value.pageQuery.current = 1;
+}
+</script>
+
+<style lang="scss" scoped>
+.list {
+  min-height: calc(100vh - var(--window-top) - var(--window-bottom));
+  width: 100vw;
+  box-sizing: border-box;
+  background: #f1f1f1;
+  position: relative;
+  // padding: 0 15px;
+  // box-sizing: border-box;
+  // background-image: url('https://pic.imgdb.cn/item/65796604c458853aef1aec2a.jpg');
+  // background-size: 100% 100%;
+  .search {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100%;
+    .search-type {
+      position: relative;
+      height: 30px;
+      line-height: 30px;
+      padding: 0 8px 0 16px;
+    }
+    .search-type::after {
+      position: absolute;
+      content: '';
+      width: 1px;
+      right: 0;
+      top: 5px;
+      bottom: 5px;
+      background: rgba(0, 0, 0, 0.25);
+    }
+    .search-type {
+      :deep(.icon-arrow) {
+        display: inline-block;
+        font-size: 20px;
+        vertical-align: middle;
+      }
+    }
+  }
+
+  .flex {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+
+    .left {
+      width: 30%;
+      margin-right: 10px;
+    }
+    .right {
+      flex: 1;
+      text-align: right;
+    }
+  }
+}
+</style>

+ 40 - 38
src/pages/settlement/list.vue

@@ -25,7 +25,7 @@
       @close="close"
       @select="select"
     />
-
+
     <template v-for="(item, index) in settlementList" :key="index">
       <wd-card :title="'开票日期:' + item.COL_0.value">
         <view class="justify-between items-center flex">
@@ -103,11 +103,11 @@ function changeSearchType({ item, index }) {
     actions.value = oilList.value;
   } else if (index === 2) {
     actions.value = userList.value;
-  }
+  }
 }
 function searchFocus() {
   showSheet.value = true;
-}
+}
 function searchChange(value) {
   // 如果输入框为空则清空 searchForm
   if (!value.value) {
@@ -117,25 +117,25 @@ function searchChange(value) {
       customerName: '',
     };
     getSettlementList();
-  }
+  }
 }
 // cancelChange
 function cancelChange(value) {
   getSettlementList();
-}
+}
 const actions = ref([]);
-// 油品名称
+// 油品名称
 const oilList = ref([{ name: '柴油' }, { name: '汽油' }]);
-// 客户名称
+// 客户名称
 const userList = ref([]);
-// 获取客户列表
+// 获取客户列表
 const getUserList = () => {
   DemoApi.getCustomerList().then((res) => {
     userList.value = res.data.map((item) => {
       return { name: item.COL_ALIAS_1 };
-    })
+    });
   });
-}
+};
 getUserList();
 const projectList = ref([]);
 const getProjectList = () => {
@@ -143,22 +143,22 @@ const getProjectList = () => {
   DemoApi.getProjectNameList().then((res) => {
     projectList.value = res.data.map((item) => {
       return { name: item.项目名称 };
-    })
+    });
     actions.value = projectList.value;
-  })
-};
+  });
+};
 getProjectList();
-
+
 function close() {
   showSheet.value = false;
-}
+}
 const searchForm = ref({
   projectName: '',
   oilName: '',
   customerName: '',
 });
 const toast = useToast();
-
+
 function select({ item, index }) {
   showSheet.value = false;
   if (searchType.value === '项目名称') {
@@ -167,9 +167,9 @@ function select({ item, index }) {
     searchForm.value.oilName = item.name;
   } else if (searchType.value === '客户名称') {
     searchForm.value.customerName = item.name;
-  }
+  }
   value.value = item.name;
-}
+}
 // 分页数据
 const pageQuery = ref({
   current: 1,
@@ -177,8 +177,8 @@ const pageQuery = ref({
   descs: 536,
   total: 0,
 });
-
-// 获取结算管理列表
+
+// 获取结算管理列表
 const formKey = ref<string>('4d62523c9ef74cdacb90146125929f37');
 const idKeyData = ref<string>('');
 const settlementList = ref([]);
@@ -188,14 +188,14 @@ const getSettlementList = () => {
     const { dbLinkId, idKey } = res.data;
     idKeyData.value = idKey;
     tableData.value = JSON.parse(res.data.tables || '[]');
-    // 匹配fieldName == menu name的值 并且再menu添加 fieldId
+    // 匹配fieldName == menu name的值 并且再menu添加 fieldId
     menu.value.map((item) => {
       tableData.value.map((table) => {
         if (table.fieldName === item.content) {
           item.fieldId = table.fieldId;
-        }
+        }
       });
-    })
+    });
     const params = {
       dbLinkId,
       pageQuery: pageQuery.value,
@@ -210,22 +210,24 @@ const getSettlementList = () => {
       };
       if (searchForm.value[item.filedName]) {
         obj.values.push(searchForm.value[item.filedName]);
-      }
+      }
       params.paramList.push(obj);
-    })
+    });
 
     DemoApi.getFormDataList(params).then((resp) => {
       const { columnDict, pageData } = resp.data;
       pageQuery.value.total = pageData.total;
       pageQuery.value.current = pageData.current;
       pageQuery.value.size = pageData.size;
-      // columnDict 是 pageData.records 和 tableData 的映射关系
-      // columnDict的key是tableData的fieldId,value是pageData.records的 key
-      // pageData.records 是后台返回的数据
-      // tableData 是前台配置的表头
+      // columnDict 是 pageData.records 和 tableData 的映射关系
+      // columnDict的key是tableData的fieldId,value是pageData.records的 key
+      // pageData.records 是后台返回的数据
+      // tableData 是前台配置的表头
       const idKey = columnDict[idKeyData.value];
+      // console.log(idKey);
       const arr = [];
       pageData.records.map((val) => {
+        console.log(val);
         const obj = {};
         obj.id = val[idKey];
         for (const key in columnDict) {
@@ -239,28 +241,28 @@ const getSettlementList = () => {
                 fieldId: item.fieldId,
                 pageDataRecordKey: columnDict[key],
               };
-            }
+            }
           });
-        }
+        }
         arr.push(obj);
-      })
-      // 回到顶部
+      });
+      // 回到顶部
       settlementList.value = arr;
-    })
+    });
   });
-}
+};
 getSettlementList();
 function handleChangePagination() {
   getSettlementList();
-}
+}
 function goEdit(item) {
   router.push({
     path: 'pages/settlement/form',
     query: { filedsData: JSON.stringify(item || '[]'), formKey: formKey.value },
   });
-}
+}
 </script>
-
+
 <style lang="scss" scoped>
 .search-type {
   position: relative;