浏览代码

前端gjy

18513069273 4 年之前
父节点
当前提交
03ab249486

+ 1 - 0
package.json

@@ -49,6 +49,7 @@
     "base-template-lib": "^1.0.7-beta",
     "base-template-lib": "^1.0.7-beta",
     "countup": "^1.8.2",
     "countup": "^1.8.2",
     "echarts": "4.2.1",
     "echarts": "4.2.1",
+    "element-china-area-data": "^5.0.2",
     "element-ui": "^2.13.2",
     "element-ui": "^2.13.2",
     "form-making-advanced": "^1.2.6",
     "form-making-advanced": "^1.2.6",
     "js-cookie": "2.2.0",
     "js-cookie": "2.2.0",

+ 2 - 1
src/api/V2/warehouse/index.js

@@ -1 +1,2 @@
-export const API_GET_WAREHOUSE_BASEINFO = '/warehouseBaseInfo/selectWarehouseViewinfo'
+export const API_GET_WAREHOUSE_BASEINFO = '/warehouseBaseInfo/selectWarehouseViewinfo'
+export const API_POST_ADD_WAREHOUSE_BASEINFO = '/warehouseBaseInfo/api/addWarehouse'

+ 3 - 2
src/components/mapdrag/mapdrag.vue

@@ -118,9 +118,9 @@ export default {
       this.map.on('click', function (e) {
       this.map.on('click', function (e) {
         var marker = new AMap.Marker({
         var marker = new AMap.Marker({
           position: new AMap.LngLat(e.lnglat.getLng(), e.lnglat.getLat()), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
           position: new AMap.LngLat(e.lnglat.getLng(), e.lnglat.getLat()), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
-          title: '北京',
         })
         })
         that.map.remove(that.markers)
         that.map.remove(that.markers)
+        that.$emit('marker', e)
         that.markers.push(marker)
         that.markers.push(marker)
         // 将创建的点标记添加到已有的地图实例:
         // 将创建的点标记添加到已有的地图实例:
         that.map.add(marker)
         that.map.add(marker)
@@ -150,6 +150,7 @@ export default {
             that.marker.setPosition(e.poi.location)
             that.marker.setPosition(e.poi.location)
             placeSearch.search() // 关键字查询查询
             placeSearch.search() // 关键字查询查询
             geocoder.getAddress(e.poi.location, function (status, result) {
             geocoder.getAddress(e.poi.location, function (status, result) {
+              console.log(status)
               if (status === 'complete') {
               if (status === 'complete') {
                 var obj = {}
                 var obj = {}
                 that.province = result.regeocode.addressComponent.province
                 that.province = result.regeocode.addressComponent.province
@@ -235,8 +236,8 @@ export default {
         }
         }
         var district = new AMap.DistrictSearch(opts) // 注意:需要使用插件同步下发功能才能这样直接使用
         var district = new AMap.DistrictSearch(opts) // 注意:需要使用插件同步下发功能才能这样直接使用
         function getData(data) {
         function getData(data) {
+          that.$emit('selectedAddress', data)
           // 清除地图上的所有覆盖物
           // 清除地图上的所有覆盖物
-          // console.log(data)
           that.areacode = data.citycode
           that.areacode = data.citycode
           var bounds = data.boundaries
           var bounds = data.boundaries
           if (data.level === 'country') {
           if (data.level === 'country') {

+ 4 - 1
src/model/warehouse/index.js

@@ -2,6 +2,9 @@ import { errorCatcher, errorHandle, filter } from 'base-core-lib'
 import { appRx } from '../defalutConfig/indexRx'
 import { appRx } from '../defalutConfig/indexRx'
 import {
 import {
     API_GET_WAREHOUSE_BASEINFO,
     API_GET_WAREHOUSE_BASEINFO,
+    API_POST_ADD_WAREHOUSE_BASEINFO
 } from '@/api/V2/warehouse'
 } from '@/api/V2/warehouse'
 // 列表
 // 列表
-export const getList = appRx.get(API_GET_WAREHOUSE_BASEINFO, errorCatcher, errorHandle, filter)
+export const getList = appRx.get(API_GET_WAREHOUSE_BASEINFO, errorCatcher, errorHandle, filter)
+// 添加
+export const addList = appRx.post(API_POST_ADD_WAREHOUSE_BASEINFO, errorCatcher, errorHandle, filter)

+ 89 - 168
src/views/warehouse/warehouseManagementAdd.vue

@@ -37,7 +37,7 @@ npm install vue-amap --save// 仓库添加
           class="readonly"
           class="readonly"
         >
         >
           <ws-input
           <ws-input
-            v-model="deptBudgetList.contractNo"
+            v-model="deptBudgetList.warehouseName"
             placeholder="请输入仓库名"
             placeholder="请输入仓库名"
             maxlength="20"
             maxlength="20"
             size="small"
             size="small"
@@ -46,7 +46,7 @@ npm install vue-amap --save// 仓库添加
         <!--负责人-->
         <!--负责人-->
         <ws-form-item label="负责人" span="1" prop="buyer" class="readonly">
         <ws-form-item label="负责人" span="1" prop="buyer" class="readonly">
           <ws-input
           <ws-input
-            v-model="deptBudgetList.buyer"
+            v-model="deptBudgetList.personCharge"
             placeholder="请输入负责人姓名"
             placeholder="请输入负责人姓名"
             maxlength="100"
             maxlength="100"
             size="small"
             size="small"
@@ -56,7 +56,7 @@ npm install vue-amap --save// 仓库添加
         <!--负责人电话-->
         <!--负责人电话-->
         <ws-form-item label="负责人电话" span="1" prop="shippingType">
         <ws-form-item label="负责人电话" span="1" prop="shippingType">
           <ws-input
           <ws-input
-            v-model="deptBudgetList.shippingType"
+            v-model="deptBudgetList.personPhone"
             placeholder="请输入负责人手机号码"
             placeholder="请输入负责人手机号码"
             maxlength="100"
             maxlength="100"
             size="small"
             size="small"
@@ -65,79 +65,26 @@ npm install vue-amap --save// 仓库添加
 
 
         <!--仓库所在地-->
         <!--仓库所在地-->
         <ws-form-item label="仓库所在地" span="1" prop="acceptanceMethod">
         <ws-form-item label="仓库所在地" span="1" prop="acceptanceMethod">
-          <el-select
-            v-model="deptBudgetList.acceptanceMethod"
-            placeholder="请选择仓库所在地"
-            style="width: 100%"
-            filterable
-            @change="selectunitList"
-          >
-            <el-option
-              v-for="(item, index) in unitList"
-              :key="item.constValue"
-              :label="item.constValue"
-              :value="item.constValue"
-            >
-              <span class="unit-left" style="float: left">
-                <span v-if="item.flag == 'delete'"> {{ item.constValue }}</span>
-                <!-- 新增文本框 -->
-                <div
-                  style="width: 160px"
-                  v-if="item.flag !== 'delete'"
-                  @click.stop
-                >
-                  <ws-input
-                    v-model="item.constValue"
-                    clearable
-                    maxlength="10"
-                    style="width: 100%"
-                  ></ws-input>
-                </div>
-              </span>
-              <span style="float: right; color: #8492a6; font-size: 13px">
-                <!-- 对号 -->
-                <i
-                  class="el-icon-check"
-                  style="line-height: 29px; margin-left: 10px"
-                  v-if="item.flag !== 'delete'"
-                  @click.stop="saveClick(item, index)"
-                ></i>
-                <!-- 编辑 -->
-                <i
-                  class="el-icon-edit"
-                  style="line-height: 29px; margin-left: 10px"
-                  v-if="item.flag == 'delete'"
-                  @click.stop="editClick(item, index)"
-                ></i>
-                <!-- 删除 -->
-                <i
-                  class="el-icon-delete"
-                  style="line-height: 29px"
-                  @click.stop="deleteClick(item, index)"
-                ></i>
-              </span>
-            </el-option>
-            <!-- 新增按钮 -->
-            <el-option value="" label="">
-              <div
-                style="
-                  text-align: right;
-                  border-top: 1px solid #dcdfe6;
-                  padding: 5px;
-                "
-              >
-                <ws-button type="primary" @click.stop="addClick">{{
-                  $t('button.add')
-                }}</ws-button>
-              </div>
-            </el-option>
-          </el-select>
+          <el-cascader
+            :options="options_"
+            v-model="selectedOptions"
+            clearable
+            size="large"
+            placeholder="请选择交货地"
+            style="width: 200%"
+            @change="handleChange"
+          />
         </ws-form-item>
         </ws-form-item>
 
 
         <!--详细地址-->
         <!--详细地址-->
-        <ws-form-item label="详细地址" span="1" prop="buyer" class="readonly">
+        <ws-form-item
+          label="详细地址"
+          span="1"
+          prop="detailedAddress"
+          class="readonly"
+        >
           <ws-input
           <ws-input
-            v-model="deptBudgetList.buyer"
+            v-model="deptBudgetList.detailedAddress"
             placeholder="请输入详细地址"
             placeholder="请输入详细地址"
             maxlength="100"
             maxlength="100"
             size="small"
             size="small"
@@ -147,12 +94,17 @@ npm install vue-amap --save// 仓库添加
         <!--总吨量(吨)-->
         <!--总吨量(吨)-->
         <ws-form-item label="总吨量(吨)" span="1" prop="settlementMethod">
         <ws-form-item label="总吨量(吨)" span="1" prop="settlementMethod">
           <ws-input
           <ws-input
-            v-model="deptBudgetList.settlementMethod"
+            :readonly="true"
+            v-model="totalStorage"
             maxlength="100"
             maxlength="100"
             size="small"
             size="small"
           />
           />
         </ws-form-item>
         </ws-form-item>
-        <div style="width: 100%" class="flex" v-for="item in freightspace">
+        <div
+          style="width: 100%"
+          class="flex position"
+          v-for="(item, index) in freightspace"
+        >
           <ws-form-item
           <ws-form-item
             label="仓库编号"
             label="仓库编号"
             span="1"
             span="1"
@@ -166,7 +118,7 @@ npm install vue-amap --save// 仓库添加
               size="small"
               size="small"
             />
             />
           </ws-form-item>
           </ws-form-item>
-          <ws-form-item label="仓位储(吨)" span="1" prop="contractNo">
+          <ws-form-item label="仓位储(吨)" span="1" prop="contractNo">
             <ws-input
             <ws-input
               v-model="item.maxStorage"
               v-model="item.maxStorage"
               placeholder="请输入仓位最大容量"
               placeholder="请输入仓位最大容量"
@@ -183,23 +135,24 @@ npm install vue-amap --save// 仓库添加
               size="small"
               size="small"
             />
             />
           </ws-form-item>
           </ws-form-item>
+          <img
+            width="22"
+            height="22"
+            class="add"
+            @click="add"
+            src="../../../public/img/add.png"
+            alt=""
+          />
+          <img
+            width="22"
+            height="22"
+            class="del"
+            @click="del(index)"
+            src="../../../public/img/del.png"
+            alt=""
+          />
         </div>
         </div>
       </ws-info-table>
       </ws-info-table>
-      <img
-        width="22"
-        height="22"
-        class="add"
-        @click="add"
-        src="../../../public/img/add.png"
-        alt=""
-      />
-      <img
-        width="22"
-        height="22"
-        class="del"
-        src="../../../public/img/del.png"
-        alt=""
-      />
     </ws-form>
     </ws-form>
     <ws-form ref="deptBudgetList" :model="deptBudgetList">
     <ws-form ref="deptBudgetList" :model="deptBudgetList">
       <ws-upload
       <ws-upload
@@ -216,7 +169,7 @@ npm install vue-amap --save// 仓库添加
       />
       />
     </ws-form>
     </ws-form>
     <!-- <ws-button @click="exportlist()"></ws-button> -->
     <!-- <ws-button @click="exportlist()"></ws-button> -->
-    <map-drag></map-drag>
+    <map-drag @marker="marker" @selectedAddress="selectedAddress"></map-drag>
     <!-- 提交 -->
     <!-- 提交 -->
     <div style="text-align: right; padding: 10px" class="center">
     <div style="text-align: right; padding: 10px" class="center">
       <el-button
       <el-button
@@ -232,6 +185,7 @@ npm install vue-amap --save// 仓库添加
 <script>
 <script>
 //  import { getVesselOne } from '@/model/procurement/basic'
 //  import { getVesselOne } from '@/model/procurement/basic'
 //  import { dayjs } from 'base-core-lib'
 //  import { dayjs } from 'base-core-lib'
+import { regionData, CodeToText, TextToCode } from 'element-china-area-data'
 import {
 import {
   packList,
   packList,
   addList,
   addList,
@@ -239,7 +193,7 @@ import {
   addxiala,
   addxiala,
   editxiala,
   editxiala,
   delxiala,
   delxiala,
-} from '@/model/contarct/index'
+} from '@/model/warehouse/index'
 import WsUpload from '@/components/WsUpload'
 import WsUpload from '@/components/WsUpload'
 import mapDrag from '@/components/mapdrag/mapdrag'
 import mapDrag from '@/components/mapdrag/mapdrag'
 export default {
 export default {
@@ -259,9 +213,13 @@ export default {
   data() {
   data() {
     let self = this
     let self = this
     return {
     return {
-      deptBudgetList: {},
+      deptBudgetList: {
+        totalStorage: 0,
+      },
+      options_: regionData,
       heightData: '600px',
       heightData: '600px',
       zoom: 7,
       zoom: 7,
+      selectedOptions: [],
       center: [116.244694, 39.517344],
       center: [116.244694, 39.517344],
       window: '',
       window: '',
       polygons: [
       polygons: [
@@ -296,81 +254,28 @@ export default {
       name: '',
       name: '',
     }
     }
   },
   },
-  activated() {
-    setTimeout(() => {
-      this.drawBounds()
-    }, 200)
+  activated() {},
+  computed: {
+    totalStorage: function () {
+      var maxStorage = 0
+      for (var i = 0; i < this.freightspace.length; i++) {
+        maxStorage += Number(this.freightspace[i].maxStorage)
+      }
+      return maxStorage
+    },
   },
   },
   methods: {
   methods: {
+    marker: function (item) {
+      this.deptBudgetList.warehousePositioning =
+        item.lnglat.lat + ',' + item.lnglat.lng
+    },
+    selectedAddress(e) {
+      this.deptBudgetList.warehousePositioning =
+        e.center.lat + ',' + e.center.lng
+    },
     confirmPositioncity() {
     confirmPositioncity() {
       this.listDate.level = 'city'
       this.listDate.level = 'city'
       this.listDate.country = this.name
       this.listDate.country = this.name
-      this.drawBounds()
-    },
-    drawBounds() {
-      var that = this
-      // 加载
-      AMap.plugin('AMap.DistrictSearch', function () {
-        var districtSearch = new AMap.DistrictSearch({
-          // 关键字对应的行政区级别,country表示国家
-          level: that.listDate.level,
-          //  显示下级行政区级数,1表示返回下一级行政区
-          subdistrict: 1,
-        })
-        // 搜索所有省/直辖市信息
-        districtSearch.search(that.listDate.country, function (status, result) {
-          if (that.listDate.level == 'country') {
-            that.citylist = result.districtList[0].districtList
-          }
-          // 查询成功时,result即为对应的行政区信息
-        })
-      })
-      var geocoder = new AMap.Geocoder({
-        radius: 1000,
-        extensions: 'all',
-        city: '全国',
-      })
-      geocoder.getLocation(that.listDate.countrys, (status, result) => {
-        if (status === 'complete' && result.geocodes.length) {
-          let lnglat = result.geocodes[0].location
-          self.lng = lnglat.lng
-          self.lat = lnglat.lat
-          self.center = [self.lng, self.lat]
-        }
-      })
-      // console.log(that.district)
-      if (!that.district) {
-        //实例化DistrictSearch
-        var opts = {
-          subdistrict: 0, //获取边界不需要返回下级行政区
-          extensions: 'all', //返回行政区边界坐标组等具体信息
-          level: that.listDate.level, //查询行政级别为 市
-        }
-        that.district = new AMap.DistrictSearch(opts)
-      }
-      //行政区查询
-      let code = that.listDate.country + ''
-      // that.district.search(code, function (status, result) {
-      // console.log(result)
-      that.polygons = []
-      // var bounds = result.districtList[0].boundaries
-      //   if (bounds) {
-      //     for (var i = 0, l = bounds.length; i < l; i++) {
-      //       //生成行政区划polygon
-      //       var polygon = new AMap.Polygon({
-      //         strokeWeight: 1,
-      //         path: bounds[i],
-      //         fillOpacity: 0.4,
-      //         fillColor: '#80d8ff',
-      //         strokeColor: '#0091ea',
-      //       })
-      //       that.polygons.push(polygon)
-      //     }
-      //   }
-      //   console.log('polygons')
-      //   AMap.Polygon.bind(that.polygons)
-      //   that.$refs.map.$amap.setFitView(that.polygons) //视口自适应
-      // })
     },
     },
     // 关闭 dialog时 处理文件url 初始化upload组件
     // 关闭 dialog时 处理文件url 初始化upload组件
     handleClose() {
     handleClose() {
@@ -383,6 +288,14 @@ export default {
         remark: '',
         remark: '',
       })
       })
     },
     },
+    del(index) {
+      if (this.freightspace.length > 1) {
+        this.freightspace.splice(index, 1)
+      }
+    },
+    handleChange(value) {
+      this.selectedOptions = value
+    },
     returnsales() {
     returnsales() {
       this.$router.push({ path: 'purchaseContract' })
       this.$router.push({ path: 'purchaseContract' })
     },
     },
@@ -410,8 +323,16 @@ export default {
     submit() {
     submit() {
       this.$refs.deptBudgetList.validate((valid) => {
       this.$refs.deptBudgetList.validate((valid) => {
         if (valid) {
         if (valid) {
-          this.deptBudgetList.compId = this.compId
-          this.deptBudgetList.contractType = 2
+          this.deptBudgetList.warehousePrivate =
+            CodeToText[this.selectedOptions[0]]
+          this.deptBudgetList.warehouseCity =
+            CodeToText[this.selectedOptions[1]]
+          this.deptBudgetList.warehouseArea =
+            CodeToText[this.selectedOptions[2]]
+          this.deptBudgetList.warehousePositionInfoList = JSON.stringify(
+            this.freightspace
+          )
+          this.deptBudgetList.totalStorage = this.totalStorage
           addList(this.deptBudgetList)
           addList(this.deptBudgetList)
             .toPromise()
             .toPromise()
             .then((response) => {
             .then((response) => {
@@ -553,12 +474,12 @@ export default {
 .add,
 .add,
 .del {
 .del {
   position: absolute;
   position: absolute;
-  right: 167px;
-  top: 94px;
+  right: -38px;
+  top: 9px;
   cursor: pointer;
   cursor: pointer;
 }
 }
 .del {
 .del {
-  right: 140px;
+  right: -70px;
 }
 }
 .amap-page-container {
 .amap-page-container {
   width: 300px;
   width: 300px;