Browse Source

fix 仓库修改

wenhongquan 3 years ago
parent
commit
689fc6fec1

+ 8 - 0
src/router/index.ts

@@ -47,6 +47,14 @@ const routes: RouteRecordRaw[] = [
         component: () => import('@/views/Warehouse/index.vue'),
       },
       {
+        path: '/warehouse/detail1',
+        component: () => import('@/views/WarehouseDetail/index.vue'),
+      },
+      {
+        path: '/warehouse/detailgoods',
+        component: () => import('@/views/WarehouseDetailGoods/index.vue'),
+      },
+      {
         path: '/warehouse/edit',
         component: () => import('@/views/WarehouseEdit/index.vue'),
       },

+ 23 - 0
src/service/warehouse.ts

@@ -46,6 +46,29 @@ export const api_getresourcedetail = (id: number) => {
   });
 };
 
+export const api_addresourcegood = (parmares: object) => {
+  return request<Object>('POST', {
+    url: `/zhdd/resourceDetail`,
+    data: parmares,
+  });
+};
+export const api_putresourcegood = (parmares: object) => {
+  return request<Object>('PUT', {
+    url: `/zhdd/resourceDetail`,
+    data: parmares,
+  });
+};
+
+export const api_delresourcegood = (id: string) => {
+  return request<Object>('DELETE', {
+    url: `/zhdd/resourceDetail/${id}`,
+  });
+};
+
+
+// 
+
+
 export const api_putresource = (parmares:object) => {
   return request<Object>('PUT', {
     url: `/zhdd/resource`,

+ 3 - 1
src/views/Warehouse/index.vue

@@ -46,7 +46,6 @@
             />
           </van-cell-group>
         </div>
-
         <div v-for="(item, index) in wzdata.aar" v-bind:key="index">
           <div class="cell-header">
             <span>应急物资({{ index + 1 }})</span>
@@ -109,6 +108,9 @@
           </van-cell-group>
         </div>
       </div>
+
+
+
       <div style="text-align: center" v-if="isedit">
         <van-button
           @click="doaddwzClick"

+ 408 - 0
src/views/WarehouseDetail/index.vue

@@ -0,0 +1,408 @@
+<template>
+  <div>
+    <van-nav-bar
+      title="应急物资"
+      left-arrow
+      placeholder
+      @click-left="goback"
+      :fixed="true"
+      @click-right="bjclick"
+    >
+      <template #right>
+        <span v-if="!isbj" class="bjbtn">办结</span>
+      </template>
+    </van-nav-bar>
+    <div v-if="!isempt">
+      <div class="content">
+        <div>
+          <van-cell-group>
+            <van-field
+              v-model="whdata.value.name"
+              label="仓库名称"
+              input-align="right"
+              :readonly="true"
+              placeholder="请输入仓库命名"
+            />
+            <!-- <van-field
+              v-model="whdata.value.manageUnit"
+              label="管理单位"
+              input-align="right"
+              :readonly="true"
+              placeholder="请输入管理单位"
+            />
+            <van-field
+              v-model="whdata.value.contactName"
+              :readonly="true"
+              label="联系人"
+              input-align="right"
+              placeholder="请输入联系人"
+            />
+            <van-field
+              v-model="whdata.value.contactPhone"
+              label="联系方式"
+              :readonly="true"
+              input-align="right"
+              placeholder="请输入联系方式"
+            /> -->
+          </van-cell-group>
+        </div>
+         <div style="text-align: right" class="addnewwz" v-if="isedit">
+        <van-button
+          @click="addwz"
+          icon="plus"
+          style="color: #0b33a8; background: rgba(0, 0, 0, 0); border: none;    margin-bottom: -10px;"
+          >新增物资</van-button
+        >
+      </div>
+
+         <div style="margin:10px 0px;background:#fff;font-size:14px;padding:10px 10px;position:relative" @click="godetail(item)" v-for="(item, index) in wzdata.aar" v-bind:key="'good'+index">
+          <div>
+              
+              <div style="font-size:14px;"><span style="color:#646566">物资名称:</span>{{item.name}} (<span style="font-size:12px;">规格:{{item.size}}</span><span style="font-size:12px;margin-left:10px">型号:{{item.model}}</span>)</div>
+               <div style="margin-top:10px">
+               <div style="font-size:14px;display:inline-block"><span style="color:#646566">可用数量:</span>{{item.availableNum}}{{item.unit}}</div>
+              <div style="font-size:14px;display:inline-block;margin-left:20px" ><span style="color:#646566">仓储数量:</span>{{item.num}}{{item.unit}}</div>
+             
+               </div>
+             
+              <div style="position: absolute;right: 10px;top: 50%;margin-top: -6px;">
+                <van-icon name="arrow" />
+              </div>
+          </div>
+
+        </div>
+
+
+        <!-- <div v-for="(item, index) in wzdata.aar" v-bind:key="index" >
+          <div class="cell-header">
+            <span>应急物资({{ index + 1 }})</span>
+            <div style="float: right" @click="deletewz(index)" v-if="isedit">删除</div>
+          </div>
+          <van-cell-group style="">
+            <van-field
+              v-model="item.name"
+              label="名称"
+              :readonly="!isedit"
+              input-align="right"
+              placeholder="请选择名称"
+            >
+             <template #button>
+               <van-button size="small" @click="selectwz(index)" type="primary" style="color:white">选择</van-button>
+             </template>
+            </van-field>
+            <van-field
+              v-model="item.model"
+              label="型号"
+               :readonly="!isedit"
+              input-align="right"
+              placeholder="请输入型号"
+            />
+            <van-field
+              v-model="item.size"
+              label="规格"
+               :readonly="!isedit"
+              input-align="right"
+              placeholder="请输入规格"
+            />
+            <van-field
+              v-model="item.num"
+              label="仓储数量"
+               :readonly="!isedit"
+              type="number"
+              input-align="right"
+              placeholder="请输入数量"
+            />
+            <van-field
+              v-model="item.availableNum"
+              label="可用数量"
+               :readonly="!isedit"
+              type="number"
+              input-align="right"
+              placeholder="请输入数量"
+            />
+            <van-field
+              v-model="item.unit"
+              label="单位"
+               :readonly="!isedit"
+              input-align="right"
+              placeholder="请输入单位"
+            />
+            <van-field name="uploader" label="图片" input-align="right">
+               <template #input>
+                 <van-uploader :max-count="1" v-model='item.pic' :before-read="beforeRead" :disabled="!isedit" />
+               </template>
+             </van-field>
+          </van-cell-group>
+        </div> -->
+      </div>
+     
+
+
+      <div style="" v-if="false">
+        <van-sticky :offset-bottom="20" position="bottom" >
+          <div style="background:#fff;width:100%;width: 100%;padding: 20px 10px;text-align: center;">
+             
+
+          </div>
+          
+
+        </van-sticky>
+       
+      </div>
+      <!-- <van-popup v-model:show="showPicker" position="bottom">
+          <van-picker
+            :columns="goodlist"
+            :default-index ="indexp"
+            @confirm="onConfirm"
+            @cancel="showPicker = false"
+          />
+      </van-popup> -->
+    </div>
+    
+    <div v-if="isempt">
+      <van-cell-group>
+            <van-field
+              v-model="whdata.value.name"
+              label="仓库名称"
+              input-align="right"
+              :readonly="true"
+              placeholder="请输入仓库命名"
+            /></van-cell-group>
+      <van-empty v-if="isempt" description="无物资" />
+         <van-button
+          type="primary"
+          block
+          style="border-radius: 30px;width: 80%;margin: auto;"
+
+          @click="addwz"
+          >新增物资</van-button
+        >
+      </div>
+  </div>
+</template>
+
+<script setup>
+import { ref, reactive, onUpdated,onMounted,watch } from 'vue';
+import { RouterView, useRoute, useRouter } from 'vue-router';
+import {
+  api_getresource,
+  api_getresourcedetail,
+  api_putresource,
+  api_bj,api_isbj,
+  api_addresourcegood,
+  api_putresourcegood,
+  api_delresourcegood
+} from '@/service/warehouse';
+import { Toast, Notify,Dialog } from 'vant';
+import { BaseMediaUrl } from '@/utils';
+import { upload } from '@/api/common';
+import { cloneDeep } from 'lodash';
+
+import { useCommonStore } from '@/store';
+import router from '@/router';
+
+
+
+const whdata = reactive({
+  value: { name: '', manageUnit: '', contactName: '', contactPhone: '' },
+});
+
+
+const isedit = ref(true);
+const isempt = ref(true);
+// let  deletwzarr = [];
+const wzdata = reactive({ aar: [] });
+
+
+
+const godetail =(item)=>{
+  localStorage.setItem("wzdata",JSON.stringify(item));
+  router.push("/warehouse/detailgoods");
+  // window.location.reload();
+}
+
+const addwz = ()=>{
+  localStorage.setItem("wzdata",JSON.stringify({
+    name: '',
+    id:"",
+    model: '',
+    size: '',
+    num: 0,
+    unit: '',
+    availableNum: '',
+    pic:"",
+    resourceId:whdata.value.id
+}));
+router.push("/warehouse/detailgoods");
+// window.location.reload();
+}
+
+
+
+const bjclick = () => {
+  if(isbj.value){
+    return;
+  }
+  Dialog.confirm({
+    title: '提示',
+    confirmButtonText: '办结',
+    message: '确认是否办结?',
+  })
+    .then(() => {
+      // on confirm
+      Toast.loading({
+        message: '加载中...',
+        duration: 0,
+        forbidClick: true,
+      });
+      api_bj({ taskId: route.query.taskid }).then((res) => {
+        Toast.clear();
+        try {
+          Toast.message("成功")
+          uni.navigateBack();
+        } catch (E) {
+        }
+      });
+      Toast.clear();
+    })
+    .catch(() => {
+      // on cancel
+      Toast.clear();
+    });
+};
+
+
+const goback = () => {
+  try {
+    uni.navigateBack();
+  } catch (E) {}
+   //window.history.back();
+};
+
+const isbj = ref(true);
+
+const route = useRoute();
+onMounted(()=>{
+  try{
+    var p = JSON.parse(localStorage.getItem('cck'));
+    if(p){
+       whdata.value = p;
+    }
+  }catch(r){
+  }
+   isedit.value = localStorage.getItem("cedit")=="true"?true:false;
+   getdata();
+   try{
+     var taskid =  route.query.taskid;
+     if(taskid){
+      api_isbj(taskid).then((res)=>{
+          isbj.value = !res.data;
+      })
+     }
+    }catch(e){}
+
+})
+
+const getdata = () => {
+  Toast.loading({
+    message: '加载中...',
+    duration: 0,
+    forbidClick: true,
+  });
+ 
+  api_getresource({
+    resourceType: 1,
+  })
+    .then((res) => {
+      Toast.clear();
+      if (res.rows.length > 0) {
+        isempt.value = false;
+        // whdata.value = res.rows.find(i=>i.id=="1481549762984415233")
+        
+        if(whdata.value.id==undefined||whdata.value.id==null||whdata.value.id==""){
+           whdata.value = res.rows[0];
+        }
+        if(whdata.value.name==undefined||whdata.value.name==null||whdata.value.name==""){
+          whdata.value.name ="";
+        }
+       
+        api_getresourcedetail(whdata.value.id).then((res1) => {
+          if (res1.data==null||
+            res1.data.resourceDetailList == null ||
+            res1.data.resourceDetailList.length == 0
+          ) {
+            // debugger
+            isempt.value = true;
+            // Toast('仓库还没有物资,请添加物资!');
+          } else {
+             isempt.value = false;
+            // res1.data.resourceDetailList.map(item=>{
+            //   if(item.pic!="" && item.pic!=null){
+            //     item.pic = [{url:BaseMediaUrl+item.pic, deletable: isedit.value,}]
+            //   }else{
+            //      item.pic = []
+            //   }
+              
+            // }) 
+            wzdata.aar = cloneDeep( res1.data.resourceDetailList);
+
+            // console.log(whdata)
+          }
+        });
+      } else {
+        Toast('未获取到仓库信息,请联系管理员!');
+      }
+    })
+    .catch((eer) => {
+      Toast.clear();
+    });
+};
+
+</script>
+
+<style lang="scss">
+.content label,
+.content span {
+  // font-size: 12px;
+  // font-family: PingFangSC, PingFangSC-Regular;
+  // color: #fff;
+}
+.addnewwz .van-button__content span{
+  color: rgb(11, 51, 168);
+  font-size: 12px;
+}
+.van-field__button .van-button__content span{
+  color: #fff;
+  font-size: 12px;
+}
+.bjbtn {
+  font-size: 14px;
+  font-weight: 500;
+  color: #ffffff;
+  font-size: 13px;
+  font-weight: 500;
+  background: #bb0000;
+  padding: 3px 8px;
+  border-radius: 2px;
+}
+.content {
+  .cell-header {
+    font-family: PingFangSC, PingFangSC-Regular;
+    font-weight: 400;
+    line-height: 42px;
+    padding: 0px 15px;
+    span {
+      font-size: 12px;
+    }
+    div {
+      font-size: 14px;
+      color: #0b33a8;
+    }
+  }
+}
+:root{
+  --van-disabled-opacity:1
+
+}
+
+</style>

+ 361 - 0
src/views/WarehouseDetailGoods/index.vue

@@ -0,0 +1,361 @@
+<template>
+  <div>
+    <van-nav-bar
+      title="应急物资编辑"
+      left-arrow
+      placeholder
+      @click-left="goback"
+      :fixed="true"
+      @click-right="bjclick"
+    >
+    </van-nav-bar>
+    <div v-if="!isempt">
+      <div class="content" style="padding-top:10px">
+        <div>
+          <van-cell-group style="">
+            <van-field
+              v-model="whdata.name"
+              label="名称"
+              :readonly="!isedit"
+              input-align="right"
+              placeholder="请选择名称"
+            >
+             <template #button>
+               <van-button size="small" @click="selectwz(0)" type="primary" style="color:white">选择</van-button>
+             </template>
+            </van-field>
+            <van-field
+              v-model="whdata.model"
+              label="型号"
+               :readonly="!isedit"
+              input-align="right"
+              placeholder="请输入型号"
+            />
+            <van-field
+              v-model="whdata.size"
+              label="规格"
+               :readonly="!isedit"
+              input-align="right"
+              placeholder="请输入规格"
+            />
+            <van-field
+              v-model="whdata.num"
+              label="仓储数量"
+               :readonly="!isedit"
+              type="number"
+              input-align="right"
+              placeholder="请输入数量"
+            />
+            <van-field
+              v-model="whdata.availableNum"
+              label="可用数量"
+               :readonly="!isedit"
+              type="number"
+              input-align="right"
+              placeholder="请输入数量"
+            />
+            <van-field
+              v-model="whdata.unit"
+              label="单位"
+               :readonly="!isedit"
+              input-align="right"
+              placeholder="请输入单位"
+            />
+            <van-field name="uploader" label="图片" input-align="right">
+               <template #input>
+                 <van-uploader :max-count="1" v-model='whdata.pic' :before-read="beforeRead" :disabled="!isedit" />
+               </template>
+             </van-field>
+          </van-cell-group>
+        </div>
+      </div>
+      
+
+<div v-if="isedit">
+  <div style="padding: 20px 20px"  v-if=" whdata.id !== ''">
+        <van-row>
+          <van-col span="11"> <van-button
+          type="danger"
+          block
+          style="border-radius: 30px"
+          @click="delgoods"
+          >删除</van-button
+        ></van-col>
+        <van-col span="2"></van-col>
+          <van-col span="11">
+             <van-button
+          type="primary"
+          block
+          style="border-radius: 30px"
+          @click="dosavedata"
+          > {{whdata.id === ""?"保存":"修改"}}</van-button
+        >
+          </van-col>
+        </van-row>
+      </div>
+       <div style="padding: 20px 20px"  v-if=" whdata.id === ''">
+       
+       
+        <van-button
+          type="primary"
+          block
+          style="border-radius: 30px"
+          @click="dosavedata"
+          > {{"保存"}}</van-button>
+         
+      </div>
+
+
+</div>
+      
+
+      <van-popup v-model:show="showPicker" position="bottom">
+          <van-picker
+            :columns="goodlist"
+            :default-index ="indexp"
+            @confirm="onConfirm"
+            @cancel="showPicker = false"
+          />
+      </van-popup>
+    </div>
+    
+    <div><van-empty v-if="isempt" description="无仓库" /></div>
+  </div>
+</template>
+
+<script setup>
+import { ref, reactive, onUpdated,onMounted,watch } from 'vue';
+import { RouterView, useRoute, useRouter } from 'vue-router';
+import {
+  api_getresource,
+  api_getresourcedetail,
+  api_putresource,
+  api_bj,api_isbj,
+  api_addresourcegood,
+  api_putresourcegood,
+  api_delresourcegood
+} from '@/service/warehouse';
+import { Toast, Notify,Dialog } from 'vant';
+import { BaseMediaUrl } from '@/utils';
+import { upload } from '@/api/common';
+import { cloneDeep } from 'lodash';
+
+import { useCommonStore } from '@/store';
+import router from '@/router';
+
+const whdata = ref({
+  id:"",
+  resourceId:"",
+  name: '',
+    model: '',
+    size: '',
+    num: 0,
+    unit: '',
+    availableNum: '',
+    pic:[]
+});
+
+const showPicker = ref(false);
+const onCancel = ()=>{
+   showPicker.value = false;
+
+}
+const onConfirm=(value)=>{
+   whdata.value.name = value;
+   showPicker.value = false;
+}
+
+const isedit = ref(true);
+const isempt = ref(false);
+// let  deletwzarr = [];
+const wzdata = reactive({ aar: [] });
+
+const beforeRead = (file,detail)=>{
+  // console.log(detail)
+  handleUpload(file);
+  return true;
+}
+
+const commonStore =  useCommonStore();
+
+const goodlist = ref([]);
+
+const selectwz = (index)=>{
+  if(!isedit.value) return;
+  showPicker.value = true;
+}
+
+
+
+
+const handleUpload = (file) => {
+         Toast.loading({
+           message: '上传中...',
+           duration: 0,
+           forbidClick: true,
+         });
+      upload(file).then((res) => {
+        Toast.clear();
+        let type = /\w+([.jpg|.png|.gif|.swf|.bmp|.jpeg]){1}$/.test(
+          res.data.fileName?.substr( res.data.fileName?.lastIndexOf('.') + 1 ) ?? '',
+        );
+       file["purl"] = res.data.url;
+      //  console.log(file)
+
+      }).catch((error) => {
+        Toast.clear();
+      });
+};
+
+
+
+const goback = () => {
+  try {
+    uni.navigateBack();
+  } catch (E) {}
+   //window.history.back();
+};
+
+const delgoods = ()=>{
+
+   Toast.loading({
+    message: '加载中...',
+    duration: 0,
+    forbidClick: true,
+  });
+  api_delresourcegood(whdata.value.id).then((res)=>{
+      Toast.clear();
+      Toast('删除成功');
+      setTimeout(() => {
+        
+        router.back();
+      }, 1000);
+
+  }).catch((ee) => {
+      Toast.clear();
+    });
+
+}
+const dosavedata = () => {
+  
+  Toast.loading({
+    message: '加载中...',
+    duration: 0,
+    forbidClick: true,
+  });
+
+  var data = cloneDeep(whdata.value);
+  if(data.pic && (data.pic ?? []).length>0){
+    if(data.pic[0].url == undefined || data.pic[0].url==null){
+       data.pic = data.pic[0].file.purl;
+    }else{
+       data.pic = data.pic[0].url.replaceAll(BaseMediaUrl,"");
+    }
+  }else{
+    data.pic = "";
+  }
+  
+  if(data.id===""){
+    //新增
+    delete data.id
+    api_addresourcegood(data).then((res)=>{
+      Toast.clear();
+      Toast('保存成功');
+      setTimeout(() => {
+        
+        router.back();
+      }, 1000);
+
+
+    }).catch((ee) => {
+      Toast.clear();
+    });
+
+  }else{
+    //修改
+     api_putresourcegood(data).then((res)=>{
+      Toast.clear();
+      Toast('保存成功');
+      setTimeout(() => {
+        router.back();
+      }, 1000);
+
+
+    }).catch((ee) => {
+      Toast.clear();
+    });
+
+  }
+
+};
+
+
+onMounted(()=>{
+  var c = async ()=>{
+    await commonStore.getGlobalDict("zhdd_resource_goods");
+    goodlist.value = commonStore.globalDict['zhdd_resource_goods']?.map(o=>o.dictLabel);
+  }
+  c();
+  try{
+    var p = JSON.parse(localStorage.getItem('wzdata'));
+    if(p){
+      if(p.pic!="" && p.pic!=null){
+          p.pic = [{url:BaseMediaUrl+p.pic, deletable: isedit.value,}]
+        }else{
+           p.pic = [];
+        }
+       whdata.value = p;
+    }
+  }catch(r){
+
+  }
+  isedit.value = localStorage.getItem("cedit")=="true"?true:false;
+ 
+
+})
+
+
+</script>
+
+<style lang="scss">
+.content label,
+.content span {
+  // font-size: 12px;
+  // font-family: PingFangSC, PingFangSC-Regular;
+  // color: #fff;
+}
+.van-field__button .van-button__content span{
+  color: #fff;
+  font-size: 12px;
+}
+.bjbtn {
+  font-size: 14px;
+  font-weight: 500;
+  color: #ffffff;
+  font-size: 13px;
+  font-weight: 500;
+  background: #bb0000;
+  padding: 3px 8px;
+  border-radius: 2px;
+}
+.content {
+  .cell-header {
+    font-family: PingFangSC, PingFangSC-Regular;
+    font-weight: 400;
+    line-height: 42px;
+    padding: 0px 15px;
+    span {
+      font-size: 12px;
+    }
+    div {
+      font-size: 14px;
+      color: #0b33a8;
+    }
+  }
+}
+:root{
+  --van-disabled-opacity:1
+
+}
+
+</style>

+ 4 - 2
src/views/WarehouseList/index.vue

@@ -63,13 +63,15 @@ const gotockedit=(item)=>{
   localStorage.setItem("cck",JSON.stringify(item))
   localStorage.setItem("cedit",true)
 
-  router.push("/warehouse/edit"+(taskid==""?"":`taskid=${taskid}`))
+  router.push("/warehouse/edit"+(taskid==""?"":`?taskid=${taskid}`));
+  // window.location.reload();
 
 }
 const gotowzedit=(item)=>{
   localStorage.setItem("cck",JSON.stringify(item))
    localStorage.setItem("cedit",true)
-  router.push("/warehouse/detail"+(taskid==""?"":`taskid=${taskid}`))
+  router.push("/warehouse/detail1"+(taskid==""?"":`?taskid=${taskid}`));
+  // window.location.reload();
 }
 
 const goback = () => {

+ 2 - 2
src/views/WarehouseListRead/index.vue

@@ -61,13 +61,13 @@ const gotockedit=(item)=>{
   localStorage.setItem("cck",JSON.stringify(item))
   localStorage.setItem("cedit",false)
 
-  router.push("/warehouse/edit"+(taskid==""?"":`taskid=${taskid}`))
+  router.push("/warehouse/edit"+(taskid==""?"":`?taskid=${taskid}`))
 
 }
 const gotowzedit=(item)=>{
   localStorage.setItem("cck",JSON.stringify(item))
    localStorage.setItem("cedit",false)
-  router.push("/warehouse/detail"+(taskid==""?"":`taskid=${taskid}`))
+  router.push("/warehouse/detail1"+(taskid==""?"":`?taskid=${taskid}`))
 }
 
 const goback = () => {