index.vue 48.5 KB
Newer Older
wanglianghe's avatar
wanglianghe committed
1 2 3 4 5
<template>
  <div class="app-container">

    <!-- 搜索工作栏 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
6

7 8
      <el-form-item :label="$t('服务网点')" prop="node" >
        <el-select v-model="queryParams.nodeId" :placeholder="$t('所属网点')" :disabled="nodeId ? true : false" clearable>
wanglianghe's avatar
wanglianghe committed
9 10 11 12
          <el-option v-for="node in nodeList" :key="node.id" :label="node.titleZh" :value="node.id"/>
        </el-select>
      </el-form-item>

13 14
      <el-form-item :label="$t('关键字')" prop="keywords">
        <el-input v-model="queryParams.keywords" :placeholder="$t('请输入仓库编号/名称')" clearable @keyup.enter.native="handleQuery"/>
wanglianghe's avatar
wanglianghe committed
15 16 17
      </el-form-item>

      <el-form-item>
18 19
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">{{$t('搜索')}}</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">{{$t('重置')}}</el-button>
wanglianghe's avatar
wanglianghe committed
20 21 22 23 24 25 26
      </el-form-item>
    </el-form>

    <!-- 操作工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5" >
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
27
                   v-hasPermi="['ecw:warehouse:create']">{{$t('新增')}}</el-button>
wanglianghe's avatar
wanglianghe committed
28 29 30
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
31
                   v-hasPermi="['ecw:warehouse:export']">{{$t('导出')}}</el-button>
wanglianghe's avatar
wanglianghe committed
32
      </el-col>
huyf's avatar
huyf committed
33 34
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="templateClick('')"
35
                   v-hasPermi="['ecw:warehouse:create']">{{$t('批量设置提单模板')}}</el-button>
huyf's avatar
huyf committed
36
      </el-col>
wanglianghe's avatar
wanglianghe committed
37 38 39 40 41
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 列表 -->
    <el-table v-loading="loading" :data="list">
42 43 44
      <el-table-column :label="$t('仓库编号')" align="center" prop="number" />
      <el-table-column :label="$t('仓库名称')" align="center" prop="titleZh" />
      <el-table-column :label="$t('英文名称')" align="center" prop="titleEn" />
45

46
      <el-table-column :label="$t('贸易属性')" align="center" prop="tradeType" >
47 48 49 50 51
          <template slot-scope="scope">
              <div>{{tradeTypeName(scope.row.tradeType)}}</div>
          </template>
      </el-table-column>

52
      <el-table-column :label="$t('运输方式')" align="center" prop="freight" >
53 54 55 56 57
          <template slot-scope="scope">
              <div>{{transportNames(scope.row.freight)}}</div>
          </template>
      </el-table-column>

58 59
      <el-table-column :label="$t('仓库容量') + '(m)³'" align="center" prop="volume" />
      <el-table-column :label="$t('仓库地址')" align="center" :prop="$l('address')" />
wanglianghe's avatar
wanglianghe committed
60

61
      <el-table-column prop="head" :label="$t('负责人')" align="center">
wanglianghe's avatar
wanglianghe committed
62 63 64 65 66 67 68 69 70
        <template slot-scope="scope">
          <div>
            <span>{{ scope.row.head }}</span>
            <br>
            <span>{{ scope.row.tell }}</span>
          </div>
        </template>
      </el-table-column>

71

72
     <el-table-column prop="status" :label="$t('状态')" width="100">
wanglianghe's avatar
wanglianghe committed
73 74 75 76
        <template slot-scope="scope">
          <el-switch v-model="scope.row.status" :active-value="CommonStatusEnum.ENABLE" :inactive-value="CommonStatusEnum.DISABLE" @change="handleStatusChange(scope.row)" />
        </template>
      </el-table-column>
77

78
      <el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width">
wanglianghe's avatar
wanglianghe committed
79
        <template slot-scope="scope">
80
          <el-button size="mini" type="text" @click="toRouteList(scope.row, '2')" :disabled="scope.row.tradeType=='2'"
81
                     v-hasPermi="['ecw:warehouse:routerQuery']">{{$t('相关始发港')}}</el-button>
82 83

          <el-button size="mini" type="text" @click="toRouteList(scope.row, '1')" :disabled="scope.row.tradeType=='1'"
84
                     v-hasPermi="['ecw:warehouse:routerQuery']">{{$t('相关目的港')}}</el-button>
85

wanglianghe's avatar
wanglianghe committed
86
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
87
                     v-hasPermi="['ecw:warehouse:update']">{{$t('修改')}}</el-button>
wanglianghe's avatar
wanglianghe committed
88 89

          <el-button size="mini" type="text" @click="bindDept(scope.row)"
90
                     v-hasPermi="['system:dept:query']">{{$t('绑定部门')}}</el-button>
wanglianghe's avatar
wanglianghe committed
91 92 93 94 95 96 97
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>

98 99
    <el-dialog :visible.sync="showRouteList" width="900px" append-to-body>
      <el-table v-loading="routeLoadig" :data="routeList">
100
      <el-table-column :label="$t('序号')" type="index" width="50" />
101

102
      <el-table-column prop="tansportType" :label="$t('运输方式')" align="center">
103 104 105 106 107 108 109
          <template slot-scope="scope">
            <div>
              {{ transportName(scope.row.transportType) }}
            </div>
          </template>
        </el-table-column>

110 111 112 113
        <el-table-column :label="$t('仓库编号')" align="center" prop="number" />
        <el-table-column :label="$t('仓库名称')" align="center" :prop="$l('title')" />
        <el-table-column :label="$t('仓库容量') + '(m)³'" align="center" prop="volume" />
        <el-table-column :label="$t('仓库地址')" align="center" :prop="$l('address')" />
114

115
        <el-table-column prop="head" :label="$t('负责人')" align="center">
116 117 118 119 120 121 122 123 124
          <template slot-scope="scope">
            <div>
              <span>{{ scope.row.head }}</span>
              <br>
              <span>{{ scope.row.tell }}</span>
            </div>
          </template>
        </el-table-column>

125
       <el-table-column :label="$t('路线服务')" align="center" prop="otherService">
wanglianghe's avatar
wanglianghe committed
126 127 128 129 130
          <template slot-scope="scope">
              <div>{{ serviceNames(scope.row.otherService) }}</div>
          </template>
       </el-table-column>

131
        <el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width">
132 133 134
          <template slot-scope="scope">
            <el-button size="mini" type="text" @click="routeStatusClick(scope.row)"
                      v-hasPermi="['ecw:warehouse:routerQuery']">{{scope.row.lineId ? '关闭线路' : '开通线路'}}</el-button>
huyf's avatar
huyf committed
135
            <el-button size="mini" type="primary" @click="templateClick(scope.row)" v-if="scope.row.lineId != null"
136
                       v-hasPermi="['ecw:warehouse:routerQuery']">{{$t('设置路线提单模板')}}</el-button>
huhaiqing's avatar
huhaiqing committed
137

wanglianghe's avatar
wanglianghe committed
138
            <el-button size="mini" type="primary" @click="serviceClick(scope.row)" v-if="scope.row.lineId != null"
139
                       v-hasPermi="['ecw:warehouse:routerQuery']">{{$t('开通服务')}}</el-button>
140 141 142 143 144 145 146 147
          </template>
        </el-table-column>
     </el-table>
    <!-- 分页组件 -->
      <pagination v-show="routeCount > 0" :total="routeCount" :page.sync="routeQueryParam.pageNo" :limit.sync="routeQueryParam.pageSize"
                @pagination="getRouteList"/>
    </el-dialog>

148
    <el-dialog :title="$t('绑定部门')" :visible.sync="deptOpen" width="500px" append-to-body>
wanglianghe's avatar
wanglianghe committed
149
        <el-header>
150
           <el-button type="primary" @click="commitBind">{{$t('提交')}}</el-button>
wanglianghe's avatar
wanglianghe committed
151
        </el-header>
152

wanglianghe's avatar
wanglianghe committed
153 154 155
      <el-table ref="multipleTable" v-if="refreshTable" :data="deptList" row-key="id" :default-expand-all="isExpandAll"
              :tree-props="{children: 'children', hasChildren: 'hasChildren'}"  @select="select" @select-all="selectAll" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55"></el-table-column>
156 157
          <el-table-column prop="name" :label="$t('部门名称')" ></el-table-column>
          <!-- <el-table-column prop="leader" :label="$t('负责人')" :formatter="userNicknameFormat" width="120"/> -->
wanglianghe's avatar
wanglianghe committed
158 159 160
      </el-table>
    </el-dialog>

wanglianghe's avatar
wanglianghe committed
161 162 163
    <!-- 对话框(添加 / 修改) -->
    <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
164 165 166
        <el-form-item :label="$t('所属网点')" prop="nodeId">
         <el-select v-model="form.nodeId" :placeholder="$t('请选择所属网点')" :disabled="(nodeId || isUpdate) ? true : false" clearable>
          <el-option v-for="node in nodeList" :key="node.id" :label="$l(node, 'title')" :value="node.id"/>
wanglianghe's avatar
wanglianghe committed
167 168 169
         </el-select>
        </el-form-item>

170 171
        <el-form-item :label="$t('所在地区')" prop="area">
          <el-select v-model="form.zhou" :placeholder="$t('请选择大洲')" @change="changeContinents">
wanglianghe's avatar
wanglianghe committed
172 173 174
            <el-option
              v-for="item in continentsList"
              :key="item.id"
175
              :label="$l(item, 'title')"
wanglianghe's avatar
wanglianghe committed
176 177 178
              :value="item.id">
            </el-option>
          </el-select>
179
          <el-select v-model="form.guojia" :placeholder="$t('请选择国家')" @change="changeCountry" v-if="form.zhou">
wanglianghe's avatar
wanglianghe committed
180 181 182
            <el-option
              v-for="item in countryList"
              :key="item.id"
183
              :label="$l(item, 'title')"
wanglianghe's avatar
wanglianghe committed
184 185 186
              :value="item.id">
            </el-option>
          </el-select>
187
          <el-select v-model="form.sheng" :placeholder="$t('请选择省')" @change="changeProvince" v-if="form.guojia">
wanglianghe's avatar
wanglianghe committed
188 189 190
            <el-option
              v-for="item in provinceList"
              :key="item.id"
191
              :label="$l(item, 'title')"
wanglianghe's avatar
wanglianghe committed
192 193 194
              :value="item.id">
            </el-option>
          </el-select>
195
          <el-select v-model="form.shi" :placeholder="$t('请选择城市')" @change="changeCity" v-if="form.sheng">
wanglianghe's avatar
wanglianghe committed
196 197 198
            <el-option
              v-for="item in cityList"
              :key="item.id"
199
              :label="$l(item, 'title')"
wanglianghe's avatar
wanglianghe committed
200 201 202 203 204
              :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>

205 206
        <el-form-item :label="$t('排序')" prop="sort">
          <el-input v-model="form.sort" type="number" :placeholder="$t('请输入排序')" />
wanglianghe's avatar
wanglianghe committed
207
        </el-form-item>
208

209 210
        <el-form-item :label="$t('仓库编号')" prop="number">
          <el-input v-model="form.number" :placeholder="$t('请输入仓库编号')" />
wanglianghe's avatar
wanglianghe committed
211
        </el-form-item>
212 213
        <el-form-item :label="$t('仓库简码')" prop="qianzhui">
          <el-input v-model="form.qianzhui" :placeholder="$t('请输入仓库简码')" />
wanglianghe's avatar
wanglianghe committed
214
        </el-form-item>
215 216
        <el-form-item :label="$t('仓库名称')" prop="titleZh">
          <el-input v-model="form.titleZh" :placeholder="$t('请输入仓库名称')" />
wanglianghe's avatar
wanglianghe committed
217
        </el-form-item>
218 219
        <el-form-item :label="$t('英文名称')" prop="titleEn">
          <el-input v-model="form.titleEn" :placeholder="$t('请输入英文名称')" />
wanglianghe's avatar
wanglianghe committed
220
        </el-form-item>
221 222
        <el-form-item :label="$t('负责人')" prop="head">
          <el-input v-model="form.head" :placeholder="$t('请输入负责人')" />
wanglianghe's avatar
wanglianghe committed
223
        </el-form-item>
224 225
        <el-form-item :label="$t('联系电话')" prop="tell">
          <el-input v-model="form.tell" :placeholder="$t('请输入联系电话')" />
wanglianghe's avatar
wanglianghe committed
226
        </el-form-item>
227 228
        <el-form-item :label="$t('容量')" prop="volume">
          <el-input v-model="form.volume" :placeholder="$t('请输入容量')">
wanglianghe's avatar
wanglianghe committed
229 230 231
            <template slot="append"></template>
          </el-input>
        </el-form-item>
232 233
        <el-form-item :label="$t('仓库地址')" prop="addressZh">
          <el-input v-model="form.addressZh" :placeholder="$t('请输入仓库地址')" />
wanglianghe's avatar
wanglianghe committed
234
        </el-form-item>
235 236
        <el-form-item :label="$t('英文地址')" prop="addressEn">
          <el-input v-model="form.addressEn" :placeholder="$t('请输入英文地址')" />
wanglianghe's avatar
wanglianghe committed
237
        </el-form-item>
238

239 240
        <el-form-item :label="$t('贸易属性')" prop="tradeType" >
          <el-select v-model="form.tradeType" :placeholder="$t('请选择')"
241 242
          >
            <!--                     :disabled="(nodeId || isUpdate) ? true : false"-->
243
            <el-option v-for="dict in regionTypeDatas" :key="dict.value" :label="$l(dict, 'label')" :value="dict.value"/>
wanglianghe's avatar
wanglianghe committed
244 245 246
          </el-select>
          </el-form-item>

247
       <el-form-item :label="$t('运输方式')" prop="checkList">
wanglianghe's avatar
wanglianghe committed
248
          <el-checkbox-group v-model="form.checkList">
249
            <el-checkbox v-for="dict in transportDatas" :label="dict.value" :key="dict.value" name="freight"> {{$l(dict, 'label')}}</el-checkbox>
wanglianghe's avatar
wanglianghe committed
250
          </el-checkbox-group>
251 252
        </el-form-item>

wanglianghe's avatar
wanglianghe committed
253
        <el-form-item label="img" prop="img">
254
          <el-col :span="8">
255
            <el-input v-model="form.img"  :placeholder="$t('请上传图片')" disabled/>
256 257 258 259
          </el-col>

           <el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload">
            <el-button size="small">
260
              {{$t('上传图片')}}
261 262 263 264
              <i class="el-icon-upload el-icon--right"></i>
            </el-button>
          </el-upload>

wanglianghe's avatar
wanglianghe committed
265 266
        </el-form-item>

267 268
        <el-form-item :label="$t('备注')" prop="remark">
          <el-input v-model="form.remark" :placeholder="$t('请输入备注')" />
wanglianghe's avatar
wanglianghe committed
269
        </el-form-item>
270

271

TIAN.DESHENG's avatar
TIAN.DESHENG committed
272 273 274 275 276 277
        <el-form-item :label="$t('会员控货下单要求')" prop="kycStatus">
          <el-radio-group v-model="form.kycStatus">
            <el-radio v-for="dict in kycDatas" :key="dict.value" :label="dict.value">{{$l(dict, 'label')}}</el-radio>
          </el-radio-group>
        </el-form-item>

wanglianghe's avatar
wanglianghe committed
278 279
      </el-form>
      <div slot="footer" class="dialog-footer">
280 281
        <el-button type="primary" @click="submitForm">{{$t('确定')}}</el-button>
        <el-button @click="cancel">{{$t('取消')}}</el-button>
wanglianghe's avatar
wanglianghe committed
282 283
      </div>
    </el-dialog>
huyf's avatar
huyf committed
284

wanglianghe's avatar
wanglianghe committed
285 286

    <!--设置服务-->
287
    <el-dialog :title="$t('设置服务')" :visible.sync="serviceOpen" width="1000px" append-to-body>
288
        <div style="font-size:large">
289 290 291 292 293
          {{$t('线路')}}:{{$t('{startName}到{destName}', {
            startName:this.startName,
            destName: this.destName
          })}}
          <span style="margin-left:20px">{{$t('运输方式')}}:{{transportName(this.lineform.transportType)}}</span>
294 295 296 297

        </div>
        <br/>

298
        <el-form ref="form" :model="lineform" :rules="rules" label-width="160px">
299
            <el-form-item :label="$t('始发港服务')">
huhaiqing's avatar
huhaiqing committed
300
              <el-checkbox-group v-model="lineform.otherService">
wanglianghe's avatar
wanglianghe committed
301 302
                <el-checkbox v-for="item in serviceGroup" :label="item.id" :key="item.id" :value="item.id"> {{item.text}}</el-checkbox>
              </el-checkbox-group>
303
            </el-form-item>
304
            <el-form-item :label="$t('目的港服务')">
305
              <el-checkbox-group  v-model="lineform.otherService">
邓春圆's avatar
邓春圆 committed
306
                <template  v-for="item in endServiceGroup" >
307
                  <el-checkbox @change="()=>{changeOtherService(item.id)}" :label="item.id " :key="item.id" :value="item.id" v-if="isShowError(item)"> {{item.text}}</el-checkbox>
邓春圆's avatar
邓春圆 committed
308
                </template>
309
              </el-checkbox-group>
huhaiqing's avatar
huhaiqing committed
310
            </el-form-item>
311
          <el-form-item v-if="['3','4'].includes(lineform.transportType)" label="空运提单制作节点">
邓春圆's avatar
邓春圆 committed
312
           <el-select v-model="lineform.makeBillNode">
313 314 315 316
             <el-option v-show="item.value !== '1'" v-for="(item, index) in getDictDatas(DICT_TYPE.AIR_SHIPMENT_PROCESS)" :label="$l(item, 'label')" :value="item.value"></el-option>
           </el-select>
          </el-form-item>
          <el-form-item label="线路是否在客户端显示">
邓春圆's avatar
邓春圆 committed
317
            <el-radio-group v-model="lineform.isClientShow">
318 319 320 321
              <el-radio :label="1">可见</el-radio>
              <el-radio :label="0">不可见</el-radio>
            </el-radio-group>
          </el-form-item>
322
          <el-form-item :label="$t('保费币种')">
邓春圆's avatar
邓春圆 committed
323
            <el-select @change="modifyAmountUnit" v-model="lineform.currencyUnit">
邓春圆's avatar
邓春圆 committed
324
              <el-option v-for="(item) in currencyList" :disabled="item.status === 1" :label="$l(item, 'title')" :value="item.id"></el-option>
325 326
            </el-select>
          </el-form-item>
邓春圆's avatar
邓春圆 committed
327 328 329
          <el-form-item :label="$t('最小保价费金额')" >
            <el-input-number  :controls="false" v-model="lineform.minPrice"  > </el-input-number>
          </el-form-item>
330
          <el-form-item :label="$t('是否支持控货')">
邓春圆's avatar
邓春圆 committed
331
            <el-radio-group v-model="lineform.controlStatus">
332 333 334 335
              <el-radio :label="0">支持</el-radio>
              <el-radio :label="1">不支持</el-radio>
            </el-radio-group>
          </el-form-item>
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361
       <template v-if="['3','4'].includes(lineform.transportType)"  >
         <el-form-item :label="$t('空运发件人')">
            <el-input v-model="lineform.senderInfo.name"  style="width: 400px" ></el-input>
         </el-form-item>
         <el-form-item :label="$t('空运发件人英文')">
           <el-input v-model="lineform.senderInfo.nameEn" style="width: 400px" ></el-input>
         </el-form-item>
         <el-form-item :label="$t('空运发件公司地址')">
           <el-input v-model="lineform.senderInfo.companyAddress" style="width: 400px" ></el-input>
         </el-form-item>
         <el-form-item :label="$t('空运发件公司地址英文')">
           <el-input  v-model="lineform.senderInfo.companyAddressEn" style="width: 400px" ></el-input>
         </el-form-item>
         <el-form-item :label="$t('空运收货人')">
           <el-input v-model="lineform.recipientInfo.name" style="width: 400px" ></el-input>
         </el-form-item>
         <el-form-item :label="$t('空运收货人英文')">
           <el-input v-model="lineform.recipientInfo.nameEn" style="width: 400px" ></el-input>
         </el-form-item>
         <el-form-item :label="$t('空运收货地址')">
           <el-input v-model="lineform.recipientInfo.companyAddress" style="width: 400px" ></el-input>
         </el-form-item>
         <el-form-item  :label="$t('空运收货地址英文')">
           <el-input v-model="lineform.recipientInfo.companyAddressEn"  style="width: 400px" ></el-input>
         </el-form-item>
       </template>
wanglianghe's avatar
wanglianghe committed
362 363 364
        </el-form>

        <div slot="footer" class="dialog-footer">
365
          <el-button type="primary" @click="submitLineForm">{{$t('保存')}}</el-button>
wanglianghe's avatar
wanglianghe committed
366 367 368
        </div>
    </el-dialog>

huyf's avatar
huyf committed
369
    <!-- 对话框(添加 / 修改) -->
dragondean@qq.com's avatar
dragondean@qq.com committed
370
    <el-dialog :title="$t('设置路线提单模板')" :visible.sync="templateOpen" width="1100px" @close="ladingFormClose()" append-to-body>
huyf's avatar
huyf committed
371
      <el-form ref="form" :model="ladingform" :rules="rules" label-width="80px">
372 373
        <el-form-item :label="$t('货柜前缀')" prop="prefixCounter">
          <el-input v-model="ladingform.prefixCounter" :placeholder="$t('请输入货柜前缀')" />
huyf's avatar
huyf committed
374
        </el-form-item>
375
        <el-form-item :label="$t('抬头')" prop="titleZh">
Marcus's avatar
Marcus committed
376
          <el-link type="primary" @click.native="setTpl('sea')">{{ $t('海运模板') }}</el-link> | <el-link type="primary" @click.native="setTpl('air')">{{ $t('空运模板') }}</el-link>
377
          <ueditor v-if="templateOpen" v-model="ladingform.titleZh" :min-height="192" style="width:960px"/>
huyf's avatar
huyf committed
378 379 380 381
        </el-form-item>

        <el-card class="box-card">
          <div slot="header" class="clearfix">
382 383
            <span>{{$t('账户详情')}}</span>
            <el-button style="float: right;" size="small" type="primary" @click="handleAddAccount">{{$t('添加账户')}}+</el-button>
huyf's avatar
huyf committed
384 385 386 387 388 389 390
          </div>
          <el-table
            :data="arr"
            style="width: 100%"
          >
            <el-table-column
              prop="detail"
huyf's avatar
huyf committed
391
              label=""
huyf's avatar
huyf committed
392 393 394
              width=""
            >
              <template v-slot="{ row, column, $index }">
huyf's avatar
huyf committed
395
                <el-input v-model="row.detail" placeholder="Account detail" size="mini"/>
huyf's avatar
huyf committed
396 397 398 399
              </template>
            </el-table-column>
            <el-table-column
              prop="name"
huyf's avatar
huyf committed
400
              label=""
huyf's avatar
huyf committed
401 402 403
              width=""
            >
              <template v-slot="{row}">
huyf's avatar
huyf committed
404
                <el-input v-model="row.name" placeholder="Account.NAME" size="mini"/>
huyf's avatar
huyf committed
405 406 407 408
              </template>
            </el-table-column>
            <el-table-column
              prop="company"
huyf's avatar
huyf committed
409
              label=""
huyf's avatar
huyf committed
410 411
            >
              <template v-slot="{row}">
huyf's avatar
huyf committed
412
                <el-input v-model="row.company" placeholder="DE-BESTDEZHI ENTERPRISE" size="mini"/>
huyf's avatar
huyf committed
413 414 415 416
              </template>
            </el-table-column>
            <el-table-column
              prop="operate"
huyf's avatar
huyf committed
417
              label=""
huyf's avatar
huyf committed
418 419
            >
              <template slot-scope="scope">
420
                <el-button type="danger" @click="delRow(scope.$index)">{{$t('删除')}}</el-button>
huyf's avatar
huyf committed
421 422 423 424 425
              </template>
            </el-table-column>
          </el-table>
        </el-card>

426
        <el-form-item :label="$t('条款')" prop="contentZh">
Marcus's avatar
Marcus committed
427 428
          <el-link type="primary" @click.native="setAgreementTpl('agreementSea')">{{ $t('海运模板') }}</el-link> |
          <el-link type="primary" @click.native="setAgreementTpl('agreementAir')">{{ $t('空运模板') }}</el-link>
429
          <ueditor v-if="templateOpen" v-model="ladingform.contentZh" :min-height="192" style="width:960px"/>
huyf's avatar
huyf committed
430
        </el-form-item>
huyf's avatar
huyf committed
431 432

        <el-form-item v-if="showFlag">
433
          <routers-selector-without-channel v-model="ladingform.lineIds" />
huyf's avatar
huyf committed
434
        </el-form-item>
huyf's avatar
huyf committed
435 436
      </el-form>
      <div slot="footer" class="dialog-footer">
437 438
        <el-button type="primary" @click="submitTemplateForm">{{$t('保存')}}</el-button>
        <el-button @click="resetTemplate()">{{$t('重置')}}</el-button>
huyf's avatar
huyf committed
439 440
      </div>
    </el-dialog>
wanglianghe's avatar
wanglianghe committed
441 442 443 444
  </div>
</template>

<script>
huyf's avatar
huyf committed
445
import { createWarehouse, updateWarehouse, deleteWarehouse, getWarehouse, getWarehousePage,createTemplate,getLadingTemplate,
wanglianghe's avatar
wanglianghe committed
446
exportWarehouseExcel,routerList,changeRouteStatus,deptBind,deptList,serviceConfig } from "@/api/ecw/warehouse";
wanglianghe's avatar
wanglianghe committed
447 448
import { getNodePage } from "@/api/ecw/node";
import { getListTree } from "@/api/ecw/region";
449
import {getDictDatas, DICT_TYPE, getDictDataL, getDictDataLabel} from '@/utils/dict'
wanglianghe's avatar
wanglianghe committed
450
import {CommonStatusEnum} from '@/utils/constants'
451
import { uploadFile } from "@/api/infra/file";
wanglianghe's avatar
wanglianghe committed
452
import { listDept } from "@/api/system/dept";
huyf's avatar
huyf committed
453
import Ueditor from '@/components/Ueditor'
huyf's avatar
huyf committed
454
import {getDictData} from '@/utils/dict'
455
import RoutersSelectorWithoutChannel from '@/components/RoutersSelectorWithoutChannel';
wanglianghe's avatar
wanglianghe committed
456
import { has } from 'min-dash';
huyf's avatar
huyf committed
457
import Template from "../../cms/template/index";
wanglianghe's avatar
wanglianghe committed
458

459 460
// 海运和空运的抬头模板
import tpl from './tpl'
461
import {getCurrencyPage} from "@/api/ecw/currency";
wanglianghe's avatar
wanglianghe committed
462 463 464
export default {
  name: "Warehouse",
  components: {
huyf's avatar
huyf committed
465
      Template,
huyf's avatar
huyf committed
466
      Ueditor,
467
    RoutersSelectorWithoutChannel
wanglianghe's avatar
wanglianghe committed
468 469 470 471
  },
  data() {
    var areaCheck = (rule, value, callback) => {
        if(!this.form.zhou) {
472
          callback(new Error(this.$t('请选择大洲')));
wanglianghe's avatar
wanglianghe committed
473
        } else if(!this.form.guojia){
474
          callback(new Error(this.$t('请选择国家/地区')));
wanglianghe's avatar
wanglianghe committed
475
        } else if(!this.form.sheng){
476
          callback(new Error(this.$t('请选择省市')));
wanglianghe's avatar
wanglianghe committed
477 478 479 480 481 482
        } else {
          callback();
        }
    };

    return {
483
      currencyList:[],
wanglianghe's avatar
wanglianghe committed
484 485 486 487 488 489 490
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,

wanglianghe's avatar
wanglianghe committed
491 492 493 494 495 496 497 498 499 500 501 502 503
      //显示绑定部门
      deptOpen: false,
      //部门列表
      deptList:[],
      // 是否展开,默认全部展开
      isExpandAll: true,
      // 重新渲染表格状态
      refreshTable: true,
      //选中的部门
      selectDeptList:[],
      //需要绑定部门的仓库id
      deptWarhouse: null,

wanglianghe's avatar
wanglianghe committed
504 505 506 507 508 509 510 511 512
      //洲际列表
      continentsList:[],
      //国家列表
      countryList:[],
      //省信息列表
      provinceList: [],
      //市信息列表
      cityList: [],

wanglianghe's avatar
wanglianghe committed
513
      serviceGroup: [
514
        {id: '1', text: this.$t('集运服务')},
wanglianghe's avatar
wanglianghe committed
515
        {id: '6', text: this.$t('数量(个)是否必填')},
516 517 518
      ],

      endServiceGroup: [
519 520 521
        {id: '3', text: this.$t('非控货订单代收货款')},
        {id: '4', text: this.$t('海外仓')},
        {id: '2', text: this.$t('送货上门')},
522 523
        {id: '5', text: this.$t('提货异常')},
        {id: '10', text: this.$t('默认送货上门')}
wanglianghe's avatar
wanglianghe committed
524 525
      ],

wanglianghe's avatar
wanglianghe committed
526 527 528 529 530 531 532 533
      // 总条数
      total: 0,
      // 仓库列表
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
huyf's avatar
huyf committed
534
      templateOpen:false,
wanglianghe's avatar
wanglianghe committed
535
      dateRangeCreateTime: [],
huhaiqing's avatar
huhaiqing committed
536

wanglianghe's avatar
wanglianghe committed
537
      serviceOpen: false,
wanglianghe's avatar
wanglianghe committed
538 539 540 541 542

      isUpdate: false,

      nodeList: [],

543 544 545 546 547 548 549 550 551 552
      routeLoadig: false,
      showRouteList: false,
      routeList: [],
      routeCount:0,
      routeQueryParam: {
        pageNo: 1,
        pageSize: 10,
        id: null,
        tradeType: null
      },
huyf's avatar
huyf committed
553
        showFlag:false,
huyf's avatar
huyf committed
554
      arr:[],
555
        cols:[{prop:"detail",label:this.$t("详情")},{prop:"name",label:this.$t("名称")},{prop:"company",label:this.$t("公司")},{prop:"operate",label:this.$t("操作")}],
wanglianghe's avatar
wanglianghe committed
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        number: null,
        titleZh: null,
        titleEn: null,
        volume: null,
        addressZh: null,
        addressEn: null,
        zhou: null,
        guojia: null,
        sheng: null,
        shi: null,
        head: null,
        tell: null,
        tradeType: null,
        freight: null,
        remark: null,
        sort: null,
        status: null,
      },
      // 表单参数
      form: {checkList:[],},
邓春圆's avatar
邓春圆 committed
580
      ladingform: {prefixCounter:null,titleZh:null,contentZh:null,account:null,acctArr:[]},
581 582 583
      lineform: {
        otherService:[],
        isClientShow:1,
邓春圆's avatar
邓春圆 committed
584
        makeBillNode:'6',
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599
        controlStatus:'0',
        currencyUnit:1,
        minPrice:0,
        "recipientInfo": {
          "companyAddress": "",
          "companyAddressEn": "",
          "name": "",
          "nameEn": ""
        },
        "senderInfo": {
          "companyAddress": "",
          "companyAddressEn": "",
          "name": "",
          "nameEn": ""
        }},
600 601
      startName:'',
      destName:'',
wanglianghe's avatar
wanglianghe committed
602

wanglianghe's avatar
wanglianghe committed
603 604
      // 表单校验
      rules: {
605
        nodeId: [{ required: true, message: this.$t("服务网点不能为空"), trigger: "blur" }],
wanglianghe's avatar
wanglianghe committed
606
        area: [{ validator:areaCheck, required: true, trigger: "blur" }],
607 608 609 610 611 612 613 614 615 616
        sort: [{ required: true, message: this.$t("排序不能为空"), trigger: "blur" }],
        number: [{ required: true, message: this.$t("仓库编号不能为空"), trigger: "blur" }],
        titleZh: [{ required: true, message: this.$t("仓库名称不能为空"), trigger: "blur" }],
        titleEn: [{ required: true, message: this.$t("英文名称不能为空"), trigger: "blur" }],
        head: [{ required: true, message: this.$t("负责人不能为空"), trigger: "blur" }],
        tell: [{ required: true, message: this.$t("联系电话不能为空"), trigger: "blur" }],
        volume: [{ required: true, message: this.$t("容量不能为空"), trigger: "blur" }],
        addressZh: [{ required: true, message: this.$t("仓库地址不能为空"), trigger: "blur" }],
        addressEn: [{ required: true, message: this.$t("英文地址不能为空"), trigger: "blur" }],
        tradeType: [{ required: true, message: this.$t('请选择网点属性'), trigger: 'change' }],
wanglianghe's avatar
wanglianghe committed
617
        checkList: [
618
            { type: 'array', required: true, message: this.$t('请至少选择一个服务内容'), trigger: 'change' }
wanglianghe's avatar
wanglianghe committed
619
          ],
wanglianghe's avatar
wanglianghe committed
620 621 622 623 624 625 626 627
      },
      nodeId: this.$route.query.nodeId,

       // 枚举
      CommonStatusEnum: CommonStatusEnum,
      // 数据字典
      statusDictDatas: getDictDatas(DICT_TYPE.COMMON_STATUS),
      regionTypeDatas: getDictDatas(DICT_TYPE.ECW_REGION_TYPE),
TIAN.DESHENG's avatar
TIAN.DESHENG committed
628 629
      transportDatas: getDictDatas(DICT_TYPE.ECW_TRANSPORT_TYPE),
      kycDatas: getDictDatas(DICT_TYPE.ECW_KYC_DATA)
wanglianghe's avatar
wanglianghe committed
630 631 632
    };
  },

633
  computed: {
邓春圆's avatar
邓春圆 committed
634 635 636 637 638
    checkedFn(){
      return (val)=>{
        return (Array.isArray(this.lineform.otherService) ? this.lineform.otherService : []).includes(val)
      }
    },
639 640 641 642 643 644
    DICT_TYPE() {
      return DICT_TYPE
    },
    getDictDataL() {
      return getDictDataL
    },
huhaiqing's avatar
huhaiqing committed
645 646
    isShowError() {
      return (item) => {
647
        if(item.id !== '5' && item.id !== '10') return true;
huhaiqing's avatar
huhaiqing committed
648
        const { otherService } = this.lineform;
邓春圆's avatar
邓春圆 committed
649
        if((Array.isArray(otherService) ? otherService : []).includes('2')) return true;
huhaiqing's avatar
huhaiqing committed
650 651 652
        return false;
      }
    },
653 654 655 656 657
    transportName() {
      return transportType => {
        for(let index in this.transportDatas) {
          let transportItem = this.transportDatas[index];
          if(transportItem.value == transportType) {
658
            return this.$l(transportItem, 'label');
659 660 661 662
          }
        }
      }
    },
663 664 665 666 667 668 669 670

    transportNames() {
      return freight => {
        let transportTypes = freight.split(",");
        let names = [];
        for(let index in transportTypes) {
          let transportType = transportTypes[index];
          let name = this.transportName(transportType);
671
          if(name)names.push(name);
672 673 674 675 676 677 678 679 680 681
        }
        return names.join(',');
      }
    },

    tradeTypeName() {
      return tradeType => {
        for(let index in this.regionTypeDatas) {
          let regionTypeItem = this.regionTypeDatas[index];
          if(regionTypeItem.value == tradeType) {
682
            return this.$l(regionTypeItem, 'label');
683 684 685 686
          }
        }
      }
    },
wanglianghe's avatar
wanglianghe committed
687 688 689 690

    serviceNames() {
      return otherService => {
        if(!otherService) return '';
huhaiqing's avatar
huhaiqing committed
691
        let serviceList = Array.isArray(otherService) ?  otherService : otherService.split(",");
wanglianghe's avatar
wanglianghe committed
692
        let names = [];
huhaiqing's avatar
huhaiqing committed
693
        const serviceGroup = this.serviceGroup.concat(this.endServiceGroup)
wanglianghe's avatar
wanglianghe committed
694 695
        for(let index in serviceList) {
          let item = serviceList[index];
huhaiqing's avatar
huhaiqing committed
696 697
          for(let dictIndex in serviceGroup) {
            let dictItem = serviceGroup[dictIndex];
wanglianghe's avatar
wanglianghe committed
698 699
            if(dictItem.id == item) {
              names.push(dictItem.text);
huhaiqing's avatar
huhaiqing committed
700
            }
wanglianghe's avatar
wanglianghe committed
701 702 703 704 705
          }
        }
        return names.join(',');
      }
    }
706 707
  },

wanglianghe's avatar
wanglianghe committed
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731
  watch: {
      'form.zhou'(newV, oldV) {
        if(oldV && oldV != newV) {
            this.form.guojia = null;
            this.form.sheng = null;
            this.form.shi = null;
        }
      },

      'form.guojia'(newV, oldV) {
          if(oldV && oldV != newV) {
            this.form.sheng = null;
            this.form.shi = null;
          }
      },

      'form.sheng'(newV, oldV) {
          if(oldV && oldV != newV) {
            this.form.shi = null;
          }
      }
    },

  created() {
732
    getCurrencyPage(this.params).then(res => this.currencyList = res.data.list)
wanglianghe's avatar
wanglianghe committed
733 734 735 736 737 738 739 740
    if(this.nodeId) {
      this.queryParams.nodeId = parseInt(this.nodeId);
    }
    this.getList();
    this.getNodeList();
    this.getContinentsList();
  },
  methods: {
741
    getDictDataLabel,
邓春圆's avatar
邓春圆 committed
742
    modifyAmountUnit(val){
邓春圆's avatar
邓春圆 committed
743

邓春圆's avatar
邓春圆 committed
744 745
      if(val === 6){
        this.lineform.minPrice = 900
邓春圆's avatar
邓春圆 committed
746 747 748 749
      } else if(val === 3){
        this.lineform.minPrice = 10
      }
      else {
邓春圆's avatar
邓春圆 committed
750 751 752
        this.lineform.minPrice = 2
      }
    },
753
    changeOtherService(val){
邓春圆's avatar
邓春圆 committed
754
      if(val === '2' && !( Array.isArray(this.lineform.otherService) ? this.lineform.otherService :[]).includes('10')){
755 756 757 758
        this.lineform.otherService.push('10');
      }
    },
    getDictDatas,
759 760 761
    setTpl(type){
      this.ladingform.titleZh = tpl[type]
    },
762 763 764
    setAgreementTpl(type){
      this.ladingform.contentZh = tpl[type]
    },
wanglianghe's avatar
wanglianghe committed
765 766 767 768 769 770 771 772 773 774 775 776 777 778
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 处理查询参数
      let params = {...this.queryParams};
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行查询
      getWarehousePage(params).then(response => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },

huyf's avatar
huyf committed
779 780 781
      delRow(index){
          this.arr.splice(index, 1);
      },
huyf's avatar
huyf committed
782 783 784
      ladingFormClose(){
          this.resetTemplate();
      },
huyf's avatar
huyf committed
785 786 787 788 789 790
    handleAddAccount(){
        const obj = {"detail": "",
            "name": "",
            "company": ""};
        this.arr.push(obj)
    },
wanglianghe's avatar
wanglianghe committed
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809
    /** 查询部门列表 */
    getDeptList() {
      listDept(this.queryParams).then(response => {
        this.deptList = this.handleTree(response.data, "id");
        //回选已选择的部门
        this.recoveryChecked();

      });
    },

    recoveryChecked() {
      for(let index in this.deptList) {
        let dept = this.deptList[index];
        this.deptChecked(dept);
      }
    },

    deptChecked(dept) {
      let deptIdList = this.deptWarhouse.deptIdList;
wanglianghe's avatar
wanglianghe committed
810
      // console.log(deptIdList);
wanglianghe's avatar
wanglianghe committed
811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826
      const hasSelect = deptIdList.some(el => {
          return dept.id === el
        })
        if(hasSelect) {
          this.toggleSelection(dept, true);
        }
        if(dept.children) {
          dept.children.map(j => {
          this.deptChecked(j);
        })
      }
    },

    // 用户昵称展示
    userNicknameFormat(row, column) {
      if (!row.leaderUserId) {
827
        return this.$t('未设置');
wanglianghe's avatar
wanglianghe committed
828 829 830 831 832 833 834
      }
      for (let index in this.users) {
        let user = this.user[index];
        if (row.leaderUserId === user.id) {
          return user.nickname;
        }
      }
Marcus's avatar
Marcus committed
835
      return this.$t('未知') + this.$t('') + row.leaderUserId + this.$t('');
wanglianghe's avatar
wanglianghe committed
836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853
    },

    /** 绑定部门 */
    bindDept(row) {
      this.deptWarhouse = row;
      this.deptOpen = true;
      this.getDeptList();
    },

    /** 展开/折叠操作 */
    toggleExpandAll() {
      this.refreshTable = false;
      this.isExpandAll = !this.isExpandAll;
      this.$nextTick(() => {
        this.refreshTable = true;
      });
    },

wanglianghe's avatar
wanglianghe committed
854 855 856 857 858 859 860
    getSelectNode(nodeId) {
      for(let index in this.nodeList) {
        let node = this.nodeList[index];
        if(node.id == nodeId) return node;
      }
    },

861 862 863 864 865 866
    // 覆盖默认的上传行为
    requestUpload() {
    },
    // 上传预处理
    beforeUpload(file) {
      if (file.type.indexOf("image/") == -1) {
867
        this.$modal.msgError(this.$t("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。"));
868 869 870 871
      } else {
        //上传
        let formData = new FormData();
        formData.append("file", file);
wanglianghe's avatar
wanglianghe committed
872
        // formData.append("path", this.uuid());
873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893
        uploadFile(formData).then(response => {
          this.$set(this.form, 'img', response.data);
          // this.form.img = response.data;
        })
      }
    },

    uuid() {
      var s = [];
      var hexDigits = "0123456789abcdef";
      for (var i = 0; i < 36; i++) {
          s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
      }
      s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
      s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
      s[8] = s[13] = s[18] = s[23] = "-";

      var uuid = s.join("");
      return uuid;
    },

wanglianghe's avatar
wanglianghe committed
894 895 896 897 898 899 900
    getContinentsList() {
        this.queryParams.treeType = 0;
        getListTree(this.queryParams).then(response => {
          this.continentsList = response.data;
      });
    },

huyf's avatar
huyf committed
901
      templateClick(row) {
huyf's avatar
huyf committed
902
        if(row!=''){
huyf's avatar
huyf committed
903 904 905 906 907 908 909 910 911 912
          getLadingTemplate(row.lineId).then(response => {
              if(response.data!=null){
                  this.ladingform = response.data;
                  var jsonArr = JSON.parse(response.data.account);
                  for (var i in jsonArr) {
                      this.arr.push(jsonArr[i]);

                  }
              }
          });
huyf's avatar
huyf committed
913 914 915 916
            this.ladingform.lineId = row.lineId;
        }else {
            this.showFlag = true;
        }
huyf's avatar
huyf committed
917 918 919
          this.templateOpen = true;
      },

wanglianghe's avatar
wanglianghe committed
920
    serviceClick(row) {
921
        if(this.routeQueryParam.tradeType == 1) {
922
          this.destName = this.$l(row, 'title');
923
        } else {
924
          this.startName = this.$l(row, 'title');
925
        }
wanglianghe's avatar
wanglianghe committed
926
        if(row.otherService) {
huhaiqing's avatar
huhaiqing committed
927
          this.lineform.otherService = Array.isArray(row.otherService) ? row.otherService : row.otherService?.split(",") ?? [];
wanglianghe's avatar
wanglianghe committed
928
        } else {
huhaiqing's avatar
huhaiqing committed
929
          this.lineform.otherService = [];
wanglianghe's avatar
wanglianghe committed
930 931 932
        }
        this.serviceOpen = true;
        this.lineform.lineId = row.lineId;
933
        this.lineform.transportType = row.transportType;
934 935
        this.lineform.isClientShow = row.isClientShow ? 1 : 0;

邓春圆's avatar
邓春圆 committed
936
        this.lineform.makeBillNode = row.makeBillNode || '6';
937 938
         this.lineform.currencyUnit =  row.currencyUnit ? row.currencyUnit : 1
         this.lineform.controlStatus =  row.controlStatus ?  row.controlStatus  : 0
939 940 941 942 943 944 945 946 947 948 949 950 951
      // 先清空 发货人和收货人信息
      this.lineform.senderInfo = {
        "companyAddress": "",
        "companyAddressEn": "",
        "name": "",
        "nameEn": ""
      }
      this.lineform.recipientInfo =   { "companyAddress": "",
        "companyAddressEn": "",
        "name": "",
        "nameEn": ""}
        Object.assign(this.lineform.recipientInfo, row.recipientInfo)
        Object.assign(this.lineform.senderInfo, row.senderInfo)
邓春圆's avatar
邓春圆 committed
952
        this.lineform.minPrice = row.minPrice ?  row.minPrice  : 0
邓春圆's avatar
邓春圆 committed
953 954 955 956 957
       if(row.minPrice){
         this.lineform.minPrice = row.minPrice;
       }else {
          if(this.lineform.currencyUnit === 6){
            this.lineform.minPrice = 900
邓春圆's avatar
邓春圆 committed
958 959 960
          } else if(this.lineform.currencyUnit === 3 ){
            this.lineform.minPrice = 10
          } else {
邓春圆's avatar
邓春圆 committed
961 962 963 964 965
            this.lineform.minPrice = 2
          }
       }


966
         console.log(row,'row')
huhaiqing's avatar
huhaiqing committed
967
    },
wanglianghe's avatar
wanglianghe committed
968 969

    submitLineForm() {
huhaiqing's avatar
huhaiqing committed
970
      let otherService = this.lineform.otherService;
huhaiqing's avatar
huhaiqing committed
971 972 973 974 975
      // 如果不存在送货上门,则过滤提货异常
      if(!otherService.includes('2')){
        otherService = otherService.filter((id) => id !== '5')
      }
      serviceConfig({
huhaiqing's avatar
huhaiqing committed
976
        lineId: this.lineform.lineId,
邓春圆's avatar
邓春圆 committed
977
        otherService: otherService.join(','),
邓春圆's avatar
邓春圆 committed
978
        isClientShow:this.lineform.isClientShow,
979
        makeBillNode:this.lineform.makeBillNode,
邓春圆's avatar
邓春圆 committed
980
        controlStatus:this.lineform.controlStatus,
邓春圆's avatar
邓春圆 committed
981
        currencyUnit:this.lineform.currencyUnit,
982 983 984 985
        minPrice:this.lineform.minPrice,
        senderInfo:this.lineform.senderInfo,
        recipientInfo:this.lineform.recipientInfo

huhaiqing's avatar
huhaiqing committed
986
        }).then(res => {
987
          this.$modal.msgSuccess(this.$t("操作成功"));
988
           this.getRouteList()
989

wanglianghe's avatar
wanglianghe committed
990 991 992 993 994 995 996 997 998 999 1000
          for(let index in this.routeList) {
            let routeItem = this.routeList[index];
            if(routeItem.lineId && routeItem.lineId == this.lineform.lineId) {
              // routeItem.otherService = otherService;
              this.$set(routeItem, 'otherService', otherService);
            }
          }
          this.serviceOpen = false;
       })
    },

1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
    routeStatusClick(row) {
      this.routeQueryParam.transportType = row.transportType;
      this.routeQueryParam.warehouseId = row.id;
      this.routeQueryParam.lineId = row.lineId;
      changeRouteStatus(this.routeQueryParam).then(response => {
        let lineId = response.data;
        this.$set(row, "lineId", lineId);
        row.lineId = lineId;
        this.$modal.msgSuccess("操作成功");
      })
    },

    toRouteList(row, tradeType) {
      this.routeQueryParam.id = row.id;
      this.routeQueryParam.tradeType = tradeType;
wanglianghe's avatar
wanglianghe committed
1016
      this.routeQueryParam.pageNo = 1;
1017 1018
      this.showRouteList = true;
      this.routeLoadig = true;
1019 1020 1021 1022 1023
      if(tradeType == 1) {
        this.startName = row.titleZh;
      } else {
        this.destName = row.titleZh;
      }
1024
      this.getRouteList();
1025

1026

1027 1028 1029 1030 1031
    },

    getRouteList() {
        routerList(this.routeQueryParam).then(response => {
          this.routeList = response.data.list;
wanglianghe's avatar
wanglianghe committed
1032
          this.routeCount = response.data.total;
1033 1034 1035 1036
          this.routeLoadig = false;
      });
    },

wanglianghe's avatar
wanglianghe committed
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076
    //获取网点列表
    getNodeList() {
      let params = {pageNo:1, pageSize:100};
      getNodePage(params).then(response => {
          this.nodeList = response.data.list;
      });
    },

      changeContinents(zhou) {
      for(let index in this.continentsList) {
        let continent = this.continentsList[index];
        if(continent.id == zhou) {
          this.countryList = continent.children;
          return;
        }
      }
    },
    changeCountry(countryId) {
      for(let index in this.countryList) {
        let country = this.countryList[index];
        if(country.id == countryId) {
          this.provinceList = country.children;
          return;
        }
      }
    },
    changeProvince(provinceId) {
      for(let index in this.provinceList) {
        let province = this.provinceList[index];
        if(province.id == provinceId) {
          this.cityList = province.children;
          return;
        }
      }
    },

    changeCity(cityId) {
      for(let index in this.cityList) {
        let city = this.cityList[index];
        if(city.id == cityId) {
1077

wanglianghe's avatar
wanglianghe committed
1078 1079 1080 1081 1082 1083
          return;
        }
      }
    },

    handleStatusChange(row) {
1084 1085
      let text = row.status === CommonStatusEnum.ENABLE ? this.$t("启用") : this.$t("停用");
      this.$modal.confirm(this.$t('确认要{action}编号为{id}的数据吗?', {action: text, id: row.id})).then(function() {
wanglianghe's avatar
wanglianghe committed
1086 1087 1088
        return updateWarehouse(row);

      }).then(() => {
1089
        this.$modal.msgSuccess(text + " " +  this.$t("成功"));
wanglianghe's avatar
wanglianghe committed
1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100
      }).catch(function() {
        row.status = row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE
          : CommonStatusEnum.ENABLE;
      });
    },

    /** 取消按钮 */
    cancel() {
      this.open = false;
      this.reset();
    },
huyf's avatar
huyf committed
1101
    resetTemplate(){
huyf's avatar
huyf committed
1102 1103
        this.arr=[];
        this.showFlag = false;
huyf's avatar
huyf committed
1104 1105 1106 1107 1108 1109 1110
        this.ladingform={
            prefixCounter:undefined,
            titleZh:undefined,
            account:undefined,
            contentZh:undefined
        }
    },
wanglianghe's avatar
wanglianghe committed
1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164
    /** 表单重置 */
    reset() {
      this.form = {
        id: undefined,
        pid: undefined,
        number: undefined,
        qianzhui: undefined,
        titleZh: undefined,
        titleEn: undefined,
        volume: undefined,
        addressZh: undefined,
        addressEn: undefined,
        zhou: undefined,
        guojia: undefined,
        sheng: undefined,
        shi: undefined,
        head: undefined,
        tell: undefined,
        tradeType: undefined,
        freight: undefined,
        remark: undefined,
        sort: undefined,
        status: undefined,
        img: undefined,
        checkList: []
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRangeCreateTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.isUpdate = false;
      if(this.nodeId) {
        //把已现在的网点的一些属性赋值给仓库
          this.form.nodeId = this.queryParams.nodeId;
          let node = this.getSelectNode(this.form.nodeId);
          this.form.zhou = node.zhou;
          this.form.guojia = node.guojia;
          this.form.sheng = node.sheng;
          this.form.shi = node.shi;
          this.form.tradeType = node.tradeType;

          this.form.checkList = node.freight.split(',');
1165

wanglianghe's avatar
wanglianghe committed
1166 1167 1168 1169 1170
          this.changeContinents(this.form.zhou);
          this.changeCountry(this.form.guojia);
          this.changeProvince(this.form.sheng);
      }
      this.open = true;
Marcus's avatar
Marcus committed
1171
      this.title = this.$t("添加仓库");
wanglianghe's avatar
wanglianghe committed
1172 1173 1174 1175 1176 1177 1178 1179
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id;
      getWarehouse(id).then(response => {
        this.form = response.data;

wanglianghe's avatar
wanglianghe committed
1180 1181 1182
        let ckList = response.data.freight.split(',');
        this.$set(this.form, 'checkList', ckList);

wanglianghe's avatar
wanglianghe committed
1183 1184 1185 1186 1187
        this.changeContinents(response.data.zhou);
        this.changeCountry(response.data.guojia);
        this.changeProvince(response.data.sheng);
        this.isUpdate = true;
        this.open = true;
1188
        this.title = this.$t("修改仓库");
wanglianghe's avatar
wanglianghe committed
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (!valid) {
          return;
        }

      //逗号拼接运输方式
      var freight = ''
      for(let i = 0; i < this.form.checkList.length; i++) {
          freight += this.form.checkList[i] + ','
      }
      freight = freight.substring(0, freight.length - 1);
      this.form.freight = freight;

        // 修改的提交
        if (this.form.id != null) {
          updateWarehouse(this.form).then(response => {
1209
            this.$modal.msgSuccess(this.$t("修改成功"));
wanglianghe's avatar
wanglianghe committed
1210 1211 1212 1213 1214 1215 1216
            this.open = false;
            this.getList();
          });
          return;
        }
        // 添加的提交
        createWarehouse(this.form).then(response => {
1217
          this.$modal.msgSuccess(this.$t("新增成功"));
wanglianghe's avatar
wanglianghe committed
1218 1219 1220 1221 1222
          this.open = false;
          this.getList();
        });
      });
    },
huyf's avatar
huyf committed
1223 1224

      submitTemplateForm(){
huyf's avatar
huyf committed
1225 1226 1227 1228 1229 1230 1231 1232
        if(this.showFlag&&this.ladingform.lineIds!=null){
            let lineId = '';
            let lineArr = this.ladingform.lineIds;
            lineArr.forEach((elem, index) => {
                lineId = lineId + elem.lineId + ",";
            });
            this.ladingform.lineId=lineId.substr(0,lineId.length-1);
        }
huyf's avatar
huyf committed
1233 1234
        this.ladingform.account = JSON.stringify(this.arr);
          createTemplate(this.ladingform).then(response => {
1235
              this.$modal.msgSuccess(this.$t("设置路线提单模板成功"));
huyf's avatar
huyf committed
1236
              this.templateOpen = false;
huyf's avatar
huyf committed
1237
              this.resetTemplate();
huyf's avatar
huyf committed
1238 1239
          });
      },
wanglianghe's avatar
wanglianghe committed
1240 1241 1242
    /** 删除按钮操作 */
    handleDelete(row) {
      const id = row.id;
1243
      this.$modal.confirm(this.$t('是否确认删除仓库编号为{id}的数据项?', {id})).then(function() {
wanglianghe's avatar
wanglianghe committed
1244 1245 1246
          return deleteWarehouse(id);
        }).then(() => {
          this.getList();
1247
          this.$modal.msgSuccess(this.$t("删除成功"));
wanglianghe's avatar
wanglianghe committed
1248 1249 1250 1251 1252 1253 1254 1255 1256 1257
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
      let params = {...this.queryParams};
      params.pageNo = undefined;
      params.pageSize = undefined;
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行导出
1258
      this.$modal.confirm(this.$t('是否确认导出所有仓库数据项?')).then(() => {
wanglianghe's avatar
wanglianghe committed
1259 1260 1261 1262 1263 1264
          this.exportLoading = true;
          return exportWarehouseExcel(params);
        }).then(response => {
          this.$download.excel(response, '${table.classComment}.xls');
          this.exportLoading = false;
        }).catch(() => {});
wanglianghe's avatar
wanglianghe committed
1265 1266 1267 1268 1269
    },

    /**提交绑定部门 */
    commitBind() {
      if(!this.selectDeptList || this.selectDeptList.length == 0) {
1270
        this.$message.error(this.$t('请先选择部门'));
wanglianghe's avatar
wanglianghe committed
1271 1272 1273 1274 1275 1276 1277 1278 1279 1280
        return;
      }
      //获取部门id列表
      let deptIdList = [];
      this.selectDeptList.map((item) => {
          deptIdList.push(item.id);
          return item;
      });
      let params = {deptIdList: deptIdList, warehouseId: this.deptWarhouse.id};
      deptBind(params).then(response => {
1281
        this.$message.success(this.$t('绑定成功'));
wanglianghe's avatar
wanglianghe committed
1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293
        let deptIdList = response.data;
        // console.log(deptIdList);

        for(let index in this.list) {
          let warehouse = this.list[index];
          if(warehouse.id == this.deptWarhouse.id) {
            warehouse.deptIdList = deptIdList;
          }
        }
        // console.log(this.list);
        this.deptOpen = false;
      })
1294

wanglianghe's avatar
wanglianghe committed
1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324
    },

    handleSelectionChange(value) {
      this.selectDeptList = value;
      // console.log(this.selectDeptList);
    },

    setChildren(children, type) {
      // 编辑多个子层级
      children.map(j => {
        this.toggleSelection(j, type)
        if (j.children) {
          this.setChildren(j.children, type)
        }
      })
    },

    // 选中父节点时,子节点一起选中取消
    select(selection, row) {
      const hasSelect = selection.some(el => {
        return row.id === el.id
      })
      if (hasSelect) {
        if (row.children) {
          // 解决子组件没有被勾选到
          this.setChildren(row.children, true)
        }

        //TODO  判断父节点的所有子节点是否都被选中
      } else {
wanglianghe's avatar
wanglianghe committed
1325
        //TODO  取消选择判断父节点的所有子节点是否都被取消
wanglianghe's avatar
wanglianghe committed
1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368
        if (row.children) {
          this.setChildren(row.children, false)
        }
      }
    },
    toggleSelection(row, select) {
      if (row) {
        this.$nextTick(() => {
          this.$refs.multipleTable &&
            this.$refs.multipleTable.toggleRowSelection(row, select)
        })
      }
    },

     // 选择全部
    selectAll(selection) {
      // console.log(selection);
      // tabledata第一层只要有在selection里面就是全选
      const isSelect = selection.some(el => {
        const tableDataIds = this.deptList.map(j => j.id)
        return tableDataIds.includes(el.id)
      })
      // tableDate第一层只要有不在selection里面就是全不选
      const isCancel = !this.deptList.every(el => {
        const selectIds = selection.map(j => j.id)
        return selectIds.includes(el.id)
      })
      if (isSelect) {
        selection.map(el => {
          if (el.children) {
            // 解决子组件没有被勾选到
            this.setChildren(el.children, true)
          }
        })
      }
      if (isCancel) {
        this.deptList.map(el => {
          if (el.children) {
            // 解决子组件没有被勾选到
            this.setChildren(el.children, false)
          }
        })
      }
wanglianghe's avatar
wanglianghe committed
1369
    }
1370

wanglianghe's avatar
wanglianghe committed
1371
  }
huhaiqing's avatar
huhaiqing committed
1372

wanglianghe's avatar
wanglianghe committed
1373 1374
};
</script>