blacklist.vue 27.9 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
        <el-form-item :label="$t('商品编码')" prop="productCode">
          <el-input v-model="queryParams.productCode" :placeholder="$t('请输入商品编码')" clearable @keyup.enter.native="handleQuery"/>
wanglianghe's avatar
wanglianghe committed
8 9
        </el-form-item>

10 11
        <el-form-item :label="$t('海关编码')" prop="customsCode">
          <el-input v-model="queryParams.customsCode" :placeholder="$t('请输入海关编码')" clearable @keyup.enter.native="handleQuery"/>
wanglianghe's avatar
wanglianghe committed
12 13
        </el-form-item>

14 15
        <el-form-item :label="$t('商品名称')" prop="titleZh">
          <el-input v-model="queryParams.titleZh" :placeholder="$t('请输入商品名称')" clearable @keyup.enter.native="handleQuery"/>
wanglianghe's avatar
wanglianghe committed
16 17
        </el-form-item>
        
18 19
        <el-form-item :label="$t('商品类型')" prop="typeId">
          <el-select v-model="queryParams.typeId" :placeholder="$t('选择商品类型')" clearable>
wanglianghe's avatar
wanglianghe committed
20 21 22 23
            <el-option v-for="type in typeList" :key="type.id" :label="type.titleZh" :value="type.id"/>
          </el-select>
        </el-form-item>

24 25
        <el-form-item :label="$t('商品特性')" prop="attrId">
          <el-select v-model="queryParams.attrId" :placeholder="$t('选择商品特性')" clearable>
wanglianghe's avatar
wanglianghe committed
26 27 28 29
            <el-option v-for="attr in attrList" :key="attr.id" :label="attr.attrName" :value="attr.id"/>
          </el-select>
       </el-form-item>
        
30
        <el-form-item :label="$t('始发地')" prop="startCityId">
wanglianghe's avatar
wanglianghe committed
31 32 33 34 35
          <el-select v-model="queryParams.startCityId" clearable>
            <el-option v-for="city in startCityList" :key="city.id" :label="city.titleZh" :value="city.id" /> 
          </el-select>
        </el-form-item>  

36
      <el-form-item :label="$t('目的地')" prop="destCityId">
wanglianghe's avatar
wanglianghe committed
37 38 39 40
        <el-select v-model="queryParams.destCityId" clearable>
          <el-option v-for="city in destCityList" :key="city.id" :label="city.titleZh" :value="city.id" /> 
        </el-select>
      </el-form-item>  
41
      <el-form-item :label="$t('空运渠道')" prop="shippingChannelId">
wanglianghe's avatar
wanglianghe committed
42 43 44 45 46 47 48
        <el-select v-model="queryParams.shippingChannelId" clearable>
          <el-option v-for="item in channelList" :key="item.id" :label="item.nameZh" :value="item.channelId" /> 
        </el-select>
      </el-form-item>  

      <el-form-item label="" prop="blacklist" v-if="false">
        <el-checkbox v-model="queryParams.blacklist"  
49
          :true-label="1" :false-label="0">{{$t('黑名单')}}</el-checkbox>
wanglianghe's avatar
wanglianghe committed
50 51 52 53 54
      </el-form-item>

  
      
      <el-form-item>
55 56
        <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
57 58 59 60 61
      </el-form-item>
    </el-form>

    <!-- 操作工具栏 -->
    <el-row :gutter="10" class="mb8">
62
      <!-- <el-col :span="1.5">
wanglianghe's avatar
wanglianghe committed
63
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
64 65
                   v-hasPermi="['ecw:product-price:create']">{{$t('新增')}}</el-button>
      </el-col> -->
wanglianghe's avatar
wanglianghe committed
66 67
      <!-- <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
68
                   v-hasPermi="['ecw:product-price:export']">{{$t('导出')}}</el-button>
wanglianghe's avatar
wanglianghe committed
69 70 71 72 73 74
      </el-col> -->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 列表 -->
    <el-table v-loading="loading" :data="list">
75
      <el-table-column :label="$t('序号')" prop="id" width="50" />
wanglianghe's avatar
wanglianghe committed
76

77
      <el-table-column :label="$t('商品编码')" align="center" prop="productCode" >
wanglianghe's avatar
wanglianghe committed
78 79 80 81 82 83 84
        <template slot-scope="scope">
            <div>
              {{ scope.row.productDO.productCode }}
            </div>
        </template>
      </el-table-column>

85
      <el-table-column :label="$t('海关编码')" align="center" prop="customsCode" >
wanglianghe's avatar
wanglianghe committed
86 87 88 89 90 91 92
        <template slot-scope="scope">
            <div>
              {{ scope.row.productDO.customsCode }}
            </div>
        </template>
      </el-table-column>

93
      <el-table-column :label="$t('商品类型')" align="center" prop="typeId">
wanglianghe's avatar
wanglianghe committed
94 95 96 97 98
        <template slot-scope="scope">
          <span>{{ getTypeName(scope.row.productDO.typeId) }}</span>
        </template>
      </el-table-column>

99
      <el-table-column :label="$t('商品名称')" align="center" prop="productName" >
wanglianghe's avatar
wanglianghe committed
100 101
        <template slot-scope="scope">
            <div>
102
              {{ $l(scope.row.productDO, 'title') }}
wanglianghe's avatar
wanglianghe committed
103 104 105 106
            </div>
        </template>
      </el-table-column>

107
      <el-table-column prop="tansportType" :label="$t('运输方式')" align="center" width="100">
wanglianghe's avatar
wanglianghe committed
108 109
          <template slot-scope="scope">
            <div>
110 111
              <dict-tag :type="DICT_TYPE.ECW_TRANSPORT_TYPE" :value="scope.row.warehouseLineDO.transportType" />
              <!-- {{ transportName(scope.row.warehouseLineDO.transportType) }} -->
wanglianghe's avatar
wanglianghe committed
112 113 114
            </div>
          </template>
      </el-table-column>
115
      <el-table-column prop="tansportType" :label="$t('出货渠道')" align="center" width="100">
wanglianghe's avatar
wanglianghe committed
116 117 118 119 120 121
          <template slot-scope="{row}">
            <div>
              {{ channelName(row.shippingChannelId) }}
            </div>
          </template>
      </el-table-column>
122
      <el-table-column prop="startDestTitle" :label="$t('始发地') + '/' + $t('目的地')" align="center">
wanglianghe's avatar
wanglianghe committed
123 124
          <template slot-scope="scope">
            <div>
125
              {{ $l(scope.row.warehouseLineDO, 'startTitle') }}
wanglianghe's avatar
wanglianghe committed
126
              <br />
127
              {{ $l(scope.row.warehouseLineDO, 'destTitle') }}
wanglianghe's avatar
wanglianghe committed
128 129 130 131
            </div>
          </template>
      </el-table-column>

132
      <el-table-column prop="price" :label="$t('价格')" align="center">
wanglianghe's avatar
wanglianghe committed
133 134
          <template slot-scope="scope">
            <div>
135
              {{$t('海运费')}}:{{ getCurrencySymbol(scope.row.transportPriceUnit) + scope.row.transportPrice}}&nbsp; 
wanglianghe's avatar
wanglianghe committed
136 137
              {{ getCurrencyTitle(scope.row.transportPriceUnit) + '/' + getUnitTitle(scope.row.transportVolumeUnit)}}
              <br />
138
              {{$t('清关费')}}:{{ getCurrencySymbol(scope.row.clearancePriceUnit) + scope.row.clearancePrice}}&nbsp; 
wanglianghe's avatar
wanglianghe committed
139 140 141 142 143
              {{ getCurrencyTitle(scope.row.clearancePriceUnit) + '/' + getUnitTitle(scope.row.clearanceVolumeUnit)}}
            </div>
          </template>
      </el-table-column>

144
      <el-table-column prop="auditStatus" align="center" :label="$t('状态')" width="120">
wanglianghe's avatar
wanglianghe committed
145 146 147 148 149 150 151
        <template slot-scope="scope">
          <div>
              {{ statusName(scope.row) }}
          </div>
        </template>
      </el-table-column>

152
      <el-table-column prop="advanceStatus" :label="$t('预付')" align="center" width="80">
wanglianghe's avatar
wanglianghe committed
153 154 155 156 157 158 159
          <template slot-scope="scope">
            <div>
              {{ getAdvanceStatuTitle(scope.row.advanceStatus) }}
            </div>
          </template>
      </el-table-column>

160
      <el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width" width="140">
wanglianghe's avatar
wanglianghe committed
161 162
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
163
                     v-hasPermi="['ecw:product-price:update']">{{$t('修改')}}</el-button>
wanglianghe's avatar
wanglianghe committed
164 165

          <el-button size="mini" type="text" icon="el-icon-edit" @click="updateStatus(scope.row, 'blacklist')"
166
                     v-hasPermi="['ecw:product-price:black']">{{ scope.row.blacklist == 0 ? $t('加入黑名单') : $t('移除黑名单') }}</el-button>
wanglianghe's avatar
wanglianghe committed
167
          <el-button size="mini" type="text" icon="el-icon-edit" @click="updateStatus(scope.row, 'auditStatus')"
168
                     v-hasPermi="['ecw:product-price:down']">{{scope.row.auditStatus == AuditStatusEnum.PASS ? $t('下架') : $t('上架')}}</el-button>
wanglianghe's avatar
wanglianghe committed
169
          <!-- <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
170
                     v-hasPermi="['ecw:product-price:delete']">{{$t('删除')}}</el-button> -->
wanglianghe's avatar
wanglianghe committed
171 172 173 174 175 176 177 178
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>

    <!-- 对话框(添加 / 修改) -->
179
    <!-- <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
wanglianghe's avatar
wanglianghe committed
180 181
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">

182 183
        <el-form-item :label="$t('商品类型')" prop="typeId">
          <el-select v-model="form.typeId" :placeholder="$t('选择产品类型')" disabled>
wanglianghe's avatar
wanglianghe committed
184 185 186 187 188
            <el-option v-for="type in typeList" :key="type.id" :label="type.titleZh" :value="type.id"/>
          </el-select>
        </el-form-item>
      

189
        <el-form-item :label="$t('商品名称')" prop="titleZh">
wanglianghe's avatar
wanglianghe committed
190 191 192
          <el-input v-model="form.titleZh"  disabled />
        </el-form-item>

193
        <el-form-item :label="$t('英文名称')" prop="titleEn">
wanglianghe's avatar
wanglianghe committed
194 195 196 197 198
          <el-input v-model="form.titleEn"  disabled />
        </el-form-item>

        <el-row :gutter="20" v-if="!form.id">
            <el-col :span="6">
199
               <el-form-item :label="$t('运输方式')" prop="transportType">
wanglianghe's avatar
wanglianghe committed
200
                  <el-select v-model="form.transportType" clearable @change="transportTypeChange">
201
                    <el-option v-for="dict in transportDatas" :key="dict.value" :label="$l(dict, 'label')" :value="dict.value" /> 
wanglianghe's avatar
wanglianghe committed
202 203 204 205
                  </el-select>
                </el-form-item>  
            </el-col>
            <el-col :span="6">
206
                <el-form-item :label="$t('始发地')" prop="startCityId">
wanglianghe's avatar
wanglianghe committed
207
                  <el-select v-model="form.startCityId" clearable @change="startCityChange">
208
                    <el-option v-for="city in startCityList" :key="city.id" :label="$l(city, 'title')" :value="city.id" /> 
wanglianghe's avatar
wanglianghe committed
209 210 211 212 213
                  </el-select>
                </el-form-item>  
            </el-col>

            <el-col :span="6">
214
              <el-form-item :label="$t('目的地')" prop="destCityId">
wanglianghe's avatar
wanglianghe committed
215
                  <el-select v-model="form.destCityId" clearable @change="destCityChange">
216
                    <el-option v-for="city in destCityList" :key="city.id" :label="$l(city, 'title')" :value="city.id" /> 
wanglianghe's avatar
wanglianghe committed
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
                  </el-select>
                </el-form-item>  
            </el-col>
            
          </el-row>

          <el-table
            ref="routeTable"
            :data="routedList"
            tooltip-effect="dark"
            max-height="250"
            style="width: 100%"
            @selection-change="handleSelectionChange">
            <el-table-column
              type="selection"
              :selectable="checkSelectable"
              width="55">
            </el-table-column>
            <el-table-column
236
              :label="$t('线路')"
wanglianghe's avatar
wanglianghe committed
237
              width="800">
238 239 240 241 242 243 244
              <template slot-scope="scope">
                {{ transportName(scope.row.transportType)}}
                {{ $t('从【{start}】发往【{dest}】', {
                  start: scope.row.startTitleZh,
                  dest: scope.row.destTitleZh
                })}}
              </template>
wanglianghe's avatar
wanglianghe committed
245 246 247 248 249 250
            </el-table-column>
          
          </el-table>

          <br />

251
          <el-form-item :label="$t('海运费')" prop="transportPrice">
wanglianghe's avatar
wanglianghe committed
252 253 254
            <el-row :gutter="20">
                <el-col :span="4">
                    <el-select v-model="form.transportPriceUnit">
255
                      <el-option v-for="currency in currecyList" :key="currency.id" :label="$l(currency, 'title')" :value="currency.id" /> 
wanglianghe's avatar
wanglianghe committed
256 257 258 259
                    </el-select>
                </el-col>

                <el-col :span="6">
260
                    <el-input v-model.number="form.transportPrice"  type="number" :placeholder="$t('整数或者两位小数')"/>
wanglianghe's avatar
wanglianghe committed
261 262 263 264
                </el-col>

                <el-col :span="4">
                    <el-select v-model="form.transportVolumeUnit">
265
                      <el-option v-for="unit in unitList" :key="unit.id" :label="$l(unit, 'title')" :value="unit.id" /> 
wanglianghe's avatar
wanglianghe committed
266 267 268 269 270
                    </el-select>
                </el-col>
            </el-row>
          </el-form-item>

271
          <el-form-item :label="$t('清关费')" prop="clearancePrice">
wanglianghe's avatar
wanglianghe committed
272 273 274
            <el-row :gutter="20">
                <el-col :span="4">
                    <el-select v-model="form.clearancePriceUnit">
275
                      <el-option v-for="currency in currecyList" :key="currency.id" :label="$l(currency, 'title')" :value="currency.id" /> 
wanglianghe's avatar
wanglianghe committed
276 277 278 279
                    </el-select>
                </el-col>

                <el-col :span="6">
280
                    <el-input v-model.number="form.clearancePrice"  type="number" :placeholder="$t('整数或者两位小数')"/>
wanglianghe's avatar
wanglianghe committed
281 282 283 284
                </el-col>

                <el-col :span="4">
                    <el-select v-model="form.clearanceVolumeUnit">
285
                      <el-option v-for="unit in unitList" :key="unit.id" :label="$l(unit, 'title')" :value="unit.id" /> 
wanglianghe's avatar
wanglianghe committed
286 287 288 289 290 291
                    </el-select>
                </el-col>
            </el-row>

          </el-form-item>

292
        <el-form-item :label="$t('是否预付')" prop="advanceStatus">
wanglianghe's avatar
wanglianghe committed
293
              <el-radio-group v-model="form.advanceStatus">
294
                <el-radio v-for="advanceDict in advanceStatusDictDatas" :key="advanceDict.value" :label="parseInt(advanceDict.value)">{{$l(advanceDict, 'label')}}</el-radio>
wanglianghe's avatar
wanglianghe committed
295 296 297 298 299
              </el-radio-group>
        </el-form-item>


        <div style="font-size:20px;">
300
          {{$t('基础信息')}}
wanglianghe's avatar
wanglianghe committed
301 302
        </div>

303 304 305
        <el-form-item :label="$t('是否预约入仓')" prop="needBook">
          <el-radio v-model.number="form.needBook" :label="1">{{$t('是')}}</el-radio>
          <el-radio v-model.number="form.needBook" :label="0">{{$t('否')}}</el-radio>
wanglianghe's avatar
wanglianghe committed
306 307
        </el-form-item>

308
        <el-form-item :label="$t('每日入仓上限')" prop="dayLimit" v-if="form.needBook == 1">
wanglianghe's avatar
wanglianghe committed
309
          <el-input v-model.number="form.dayLimit" type="number">
310
            <template slot="append">{{$t('立方米')}}</template>
wanglianghe's avatar
wanglianghe committed
311 312 313
          </el-input>
        </el-form-item>

314 315
        <el-form-item :label="$t('货柜位置')" prop="containerLocation">
          <el-select v-model="form.containerLocation" :placeholder="$t('选择货柜位置')" clearable>
wanglianghe's avatar
wanglianghe committed
316 317 318 319
            <el-option v-for="locationItem in locationList" :key="locationItem.value" :label="locationItem.label" :value="locationItem.value"/>
          </el-select>
        </el-form-item>

320
        <el-form-item :label="$t('订单方数上限')" prop="square">
wanglianghe's avatar
wanglianghe committed
321
          <el-input v-model.number="form.square" type="number">
322
            <template slot="append">{{$t('立方米')}}</template>
wanglianghe's avatar
wanglianghe committed
323 324 325 326 327 328
          </el-input>
        </el-form-item>

      </el-form>

      <div slot="footer" class="dialog-footer">
329 330
        <el-button type="primary" @click="submitForm">{{$t('确定')}}</el-button>
        <el-button @click="cancel">{{$t('取消')}}</el-button>
wanglianghe's avatar
wanglianghe committed
331
      </div>
332
    </el-dialog> -->
wanglianghe's avatar
wanglianghe committed
333 334 335 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 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
  </div>
</template>

<script>
import { createProductPrice, updateProductPrice, deleteProductPrice, getProductPrice, getProductPricePage, exportProductPriceExcel } from "@/api/ecw/productPrice";
import { openedRouterList } from "@/api/ecw/warehouse";
import { getCityList } from "@/api/ecw/region";
import { getProductTypeList } from "@/api/ecw/productType";
import { getProductAttrList } from "@/api/ecw/productAttr";
import { getDictDatas, DICT_TYPE } from '@/utils/dict'
import { getCurrencyList } from '@/api/ecw/currency';
import { getUnitList } from '@/api/ecw/unit';
import { AuditStatusEnum} from '@/utils/constants'
import { getChannelList } from '@/api/ecw/channel';
import DictTag from '@/components/DictTag'
import {arrryToKeyedObjectBy} from '@/utils/index'
export default {
  name: "ProductPrice",
  components: {
    DictTag
  },
  data() {
    return {
      //特性列表
      attrList:[],
      typeList: [],
      product: null,
      startCityList: [],  //始发地城市
      destCityList: [],   //目的地城市
      routedList: [],     //已开头路线列表
      currecyList: [],    //货币列表
      unitList: [],       //单位列表
      channelList:[] , // 渠道
      routeParams:{},    //路线搜索条件
      isUpdate: false,   //更新操作

      //货柜位置
      locationList:[],

      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 产品价格列表
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      dateRangeCreateTime: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        productId: null,
        warehouseLineId: null,
        transportType: null,
        transportPrice: null,
        transportPriceUnit: null,
        transportVolumeUnit: null,
        clearancePrice: null,
        clearancePriceUnit: null,
        clearanceVolumeUnit: null,
        shippingChannelId: null,
        status: null,
      },
      // 表单参数
      form: {
        typeId: null,
        titleZh: null
      },
      // 表单校验
409
      /* rules: {
Marcus's avatar
Marcus committed
410 411 412 413 414 415 416 417 418
        typeId: [{ required: true, message: this.$t("产品类型不能为空"), trigger: "blur" }],
        titleZh: [{ required: true, message: this.$t("产品名称不能为空"), trigger: "blur" }],
        titleEn: [{ required: true, message: this.$t("英文名称不能为空"), trigger: "blur" }],
        transportPrice: [{ required: true, message: this.$t("海运费不能为空"), trigger: "blur" }],
        clearancePrice: [{ required: true, message: this.$t("清关费不能为空"), trigger: "blur" }],
        advanceStatus: [{ required: true, message: this.$t("是否预付不能为空"), trigger: "blur" }],
        containerLocation:[{ required: true, message: this.$t("货柜位置不能为空"), trigger: "blur" }],
        square:[{ required: true, message: this.$t("方数不能为空"), trigger: "blur" }],
        needBook:[{ required: true, message: this.$t("预约入仓不能为空"), trigger: "blur" }],
419
      }, */
wanglianghe's avatar
wanglianghe committed
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435

      lineList: [],
      transportDatas: getDictDatas(DICT_TYPE.ECW_TRANSPORT_TYPE),
      advanceStatusDictDatas: getDictDatas(DICT_TYPE.ADVANCE_STATUS),
      AuditStatusEnum: AuditStatusEnum,
      locationList: getDictDatas(DICT_TYPE.ECW_CONTAINER_LOCATION),
      
    };
  },

  computed: {
    keyedChannel(){
      return arrryToKeyedObjectBy(this.channelList, 'channelId')
    },
    channelName(){
      return id => {
436
        return this.keyedChannel[id] ? this.$l(this.keyedChannel[id], 'name') : null
wanglianghe's avatar
wanglianghe committed
437 438 439 440 441 442 443
      }
    },
    getTypeName() {
      return typeId => {
        for(let index in this.typeList) {
          let typeItem = this.typeList[index];
          if(typeItem.id == typeId) {
444
            return this.$l(typeItem, 'title');
wanglianghe's avatar
wanglianghe committed
445 446 447 448 449 450 451
          }
        }
      }
    },

    statusName() {
      return row => {
452 453 454
        if(row.blacklist) return this.$t('黑名单');
        if(row.auditStatus === AuditStatusEnum.PASS) return this.$t('已审核');
        return this.$t('已下架');
wanglianghe's avatar
wanglianghe committed
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
      }
    },

    transportName() {
      return transportType => {
        return this.getDictDataLabel(this.DICT_TYPE.ECW_TRANSPORT_TYPE, transportType)
        /* for(let index in this.transportDatas) {
          let transportItem = this.transportDatas[index];
          if(transportItem.value == transportType) {
            return transportItem.label;
          }
        } */
      }
    },

    getCurrencySymbol() {
      return currencyId => {
        for(let index in this.currecyList) {
          let currecyItem = this.currecyList[index];
          if(currecyItem.id == currencyId) {
            return currecyItem.fuhao;
          }
        }
      }
    },

    getCurrencyTitle() {
      return currencyId => {
        for(let index in this.currecyList) {
          let currecyItem = this.currecyList[index];
          if(currecyItem.id == currencyId) {
486
            return this.$l(currecyItem, 'title');
wanglianghe's avatar
wanglianghe committed
487 488 489 490 491 492 493 494 495 496
          }
        }
      }
    },

    getUnitTitle() {
      return unitId => {
        for(let index in this.unitList) {
          let unitItem = this.unitList[index];
          if(unitItem.id == unitId) {
497
            return this.$l(unitItem, 'title');
wanglianghe's avatar
wanglianghe committed
498 499 500 501 502 503 504 505 506 507
          }
        }
      }
    },

    getAdvanceStatuTitle() {
      return value => {
        for(let index in this.advanceStatusDictDatas) {
          let dictItem = this.advanceStatusDictDatas[index];
          if(dictItem.value === '' + value) {
508
            return this.$l(dictItem, 'label');
wanglianghe's avatar
wanglianghe committed
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524
          }
        }
      }
    }
  },

  created() {
    this.queryParams.blacklist = 1;
    
    
    // this.transportDatas = getDictDatas(DICT_TYPE.ECW_TRANSPORT_TYPE);
    // console.log(this.transportDatas);
    let productJson = localStorage.getItem('product');
    // console.log(productJson);
    this.product = eval('(' + productJson + ')');

525
    this.getTypeList();
wanglianghe's avatar
wanglianghe committed
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621
    this.getChannelList()
   
    this.getAttrList();
    this.getList();
    //获取城市列表
    this.getAllCityList();
    //获取货币列表
    this.requestCurrencyList();
    //获取单位列表
    this.requestUnitList();
  },



  methods: {
    getChannelList(){
      getChannelList().then(res => this.channelList = res.data)
    },
    /** 获取产品属性列表 */
    getAttrList() {
      getProductAttrList().then(response => {
          this.attrList = response.data;
      })
    },

     /** 获取产品类型列表 */
    getTypeList() {
      getProductTypeList().then(response => {
        this.typeList = response.data;
      })
    },

    /**获取所有城市列表 */
    getAllCityList() {
      getCityList({}).then(response => {
          let cityList = response.data;
          for(let index in cityList) {
            let city = cityList[index];
            if(city.type == '1') {  //进口,目的地
              this.destCityList.push(city);
            } else if(city.type == '2') {  //出口,始发地
              this.startCityList.push(city);
            } else if(city.type == '3') {   //进出口
              this.destCityList.push(city);
              this.startCityList.push(city);
            }
          }
      })
    },

    /**获取已开通路线列表 */
    getOpenedRouterList() {
        openedRouterList(this.routeParams).then(response => {
            this.routedList = response.data;
            this.setDefaultSelect();
        })
    },

    /**获取所有货币列表 */
    requestCurrencyList() {
      getCurrencyList().then(response => {
        this.currecyList = response.data;
      }) 
    },

    /**获取所有单位列表 */
    requestUnitList() {
      getUnitList().then(response => {
        this.unitList = response.data;
      })
    },

    handleSelectionChange(val) {
        this.lineList = val;
    },

    /**运输线路改变 */
    transportTypeChange(newVal) {
      this.routeParams.transportType = this.form.transportType;
      this.getOpenedRouterList();
    },

    /**始发地改变 */
    startCityChange(newVal) {
      this.routeParams.startCityId = this.form.startCityId;
      this.getOpenedRouterList();
    },

    /**目的地改变 */
    destCityChange(newVal) {
      this.routeParams.destCityId = this.form.destCityId;
      this.getOpenedRouterList();
    },

     handleStatusChange(row) {
      updateProductPrice(row).then(() => {
622
        this.$modal.msgSuccess(this.$t("修改成功"));
wanglianghe's avatar
wanglianghe committed
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641
      }).catch(function() {
        row.auditStatus = row.auditStatus === AuditStatusEnum.PASS ? AuditStatusEnum.NOT_PASS : AuditStatusEnum.PASS;
      });
    },

    /** 查询列表 */
    getList() {
      this.loading = true;
      // 处理查询参数
      let params = {...this.queryParams};
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行查询
      getProductPricePage(params).then(response => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 取消按钮 */
642
    /* cancel() {
wanglianghe's avatar
wanglianghe committed
643 644
      this.open = false;
      this.reset();
645
    }, */
wanglianghe's avatar
wanglianghe committed
646
    /** 表单重置 */
647
    /* reset() {
wanglianghe's avatar
wanglianghe committed
648 649 650 651 652 653 654 655 656 657 658 659
      this.form = {
        id: undefined,
        productId: undefined,
        warehouseLineId: undefined,
        transportPrice: undefined,
        transportPriceUnit: undefined,
        transportVolumeUnit: undefined,
        clearancePrice: undefined,
        clearancePriceUnit: undefined,
        clearanceVolumeUnit: undefined,
        status: undefined,
      };
660 661
      this.resetForm(this.$t("form"));
    }, */
wanglianghe's avatar
wanglianghe committed
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRangeCreateTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {
      return this.$router.push('product-price/edit?' + (new URLSearchParams(this.$route.query)).toString())
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
679
      return this.$router.push('product-price/edit?action=update&id=' + row.id)
wanglianghe's avatar
wanglianghe committed
680 681 682 683 684 685 686 687 688
    },

    updateStatus(row, type) {
      if(type == 'blacklist') {
        row.blacklist=row.blacklist == 0 ? 1 : 0;
      } else if(type == 'auditStatus') {
        row.auditStatus=row.auditStatus === AuditStatusEnum.PASS ? AuditStatusEnum.NOT_PASS : AuditStatusEnum.PASS;
      }
      updateProductPrice(row).then(() => {
689
        this.$modal.msgSuccess(this.$t("修改成功"));
wanglianghe's avatar
wanglianghe committed
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723
      }).catch(function() {
        if(statusType == 'blacklist') {
          row.blacklist = row.blacklist === 1 ? 0 : 1;
        } else {
          row.auditStatus = row.auditStatus === AuditStatusEnum.PASS ? AuditStatusEnum.NOT_PASS : AuditStatusEnum.PASS;
        }
        
      });
    },

    
    checkSelectable() {
      return !this.isUpdate;
    },


    setDefaultSelect() {
      let vm = this;
      setTimeout(() => {
         // 修改线路价格,选中已经选择的
        if(vm.isUpdate && vm.routedList && vm.routedList.length) {
            vm.$refs.routeTable.toggleRowSelection(vm.routedList[0]);
        }
      }, 300);
    },

    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (!valid) {
          return;
        }

        if(!this.lineList || !this.lineList.length) {
724
            this.$message.error(this.$t('请选择线路'));
wanglianghe's avatar
wanglianghe committed
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746
            return;
        }
        let lineChannelList = [];
        //TODO  ,lineChannelList实体空运的时候需要传出货渠道ID--shippingChannelId
        this.lineList.map((item) => {
            lineChannelList.push({lineId: item.id});
            return item;
        });
        this.form.lineChannelList = lineChannelList;

        // 修改的提交
        if (this.form.id != null) {
          updateProductPrice(this.form).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.open = false;
            this.getList();
          });
          return;
        }
        // 添加的提交
        this.form.productId = this.product.id;
        createProductPrice(this.form).then(response => {
747
          this.$modal.msgSuccess(this.$t("请求成功"));
wanglianghe's avatar
wanglianghe committed
748 749 750 751 752 753 754 755
          this.open = false;
          this.getList();
        });
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const id = row.id;
756
      this.$modal.confirm(this.$t('是否确认删除产品价格编号为{id}的数据项?', {id})).then(function() {
wanglianghe's avatar
wanglianghe committed
757 758 759
          return deleteProductPrice(id);
        }).then(() => {
          this.getList();
760
          this.$modal.msgSuccess(this.$t("删除成功"));
wanglianghe's avatar
wanglianghe committed
761 762 763 764 765 766 767 768 769 770
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
      let params = {...this.queryParams};
      params.pageNo = undefined;
      params.pageSize = undefined;
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行导出
771
      this.$modal.confirm(this.$t('是否确认导出所有产品价格数据项?')).then(() => {
wanglianghe's avatar
wanglianghe committed
772 773 774 775 776 777 778 779 780
          this.exportLoading = true;
          return exportProductPriceExcel(params);
        }).then(response => {
          this.$download.excel(response, '${table.classComment}.xls');
          this.exportLoading = false;
        }).catch(() => {});
    }
  }
};
781
</script>