index.vue 29.2 KB
Newer Older
wanglianghe's avatar
wanglianghe committed
1 2
<template>
  <div class="app-container">
dragondean@qq.com's avatar
dragondean@qq.com committed
3
    <div class="page-title">{{$route.query.product_id ? productTitle + '-' : this.$t('全部')}}{{$t('路线价格列表')}}</div>
wanglianghe's avatar
wanglianghe committed
4
    <!-- 搜索工作栏 -->
wanglianghe's avatar
wanglianghe committed
5
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
Marcus's avatar
Marcus committed
6 7
        <!-- <el-form-item :label="$t('商品编码')" prop="productCode" v-if="!$route.query.product_id">
          <el-input v-model="queryParams.productCode" :placeholder="$t('请输入商品编码')" clearable @keyup.enter.native="handleQuery"/>
8 9
        </el-form-item>

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

dragondean@qq.com's avatar
dragondean@qq.com committed
14 15
        <el-form-item :label="$t('商品名称')" prop="titleZh" v-if="!$route.query.product_id">
          <el-input v-model="queryParams.titleZh" :placeholder="$t('请输入中英文名称、商品编码、海关编码')" clearable @keyup.enter.native="handleQuery"/>
16
        </el-form-item>
17

dragondean@qq.com's avatar
dragondean@qq.com committed
18 19
        <el-form-item :label="$t('商品类型')" prop="typeId" v-if="!$route.query.product_id">
          <el-select v-model="queryParams.typeId" :placeholder="$t('选择商品类型')" clearable>
20 21 22
            <el-option v-for="type in typeList" :key="type.id" :label="type.titleZh" :value="type.id"/>
          </el-select>
        </el-form-item>
Marcus's avatar
Marcus committed
23 24
        <!-- <el-form-item :label="$t('商品属性')" prop="attrId" v-if="!$route.query.product_id">
          <el-select v-model="queryParams.attrId" :placeholder="$t('选择商品属性')" clearable>
25 26
            <el-option v-for="attr in attrList" :key="attr.id" :label="attr.attrName" :value="attr.id"/>
          </el-select>
27
        </el-form-item>
Marcus's avatar
Marcus committed
28
        <el-form-item :label="$t('商品特性')" prop="attrId" v-if="!$route.query.product_id">
29
          // TODO
30
        </el-form-item> -->
dragondean@qq.com's avatar
dragondean@qq.com committed
31
        <el-form-item :label="$t('运输方式')" prop="transportType">
dragondean@qq.com's avatar
dragondean@qq.com committed
32
          <dict-selector :type="DICT_TYPE.ECW_TRANSPORT_TYPE" v-model="queryParams.transportType" formatter="number" clearable />
33
        </el-form-item>
dragondean@qq.com's avatar
dragondean@qq.com committed
34
        <el-form-item :label="$t('出货渠道')" prop="shippingChannelId">
35
        <el-select v-model="queryParams.shippingChannelId" clearable>
36
          <el-option v-for="item in channelList" :key="item.id" :label="$l(item, 'name')" :value="item.channelId" />
37
        </el-select>
38
      </el-form-item>
dragondean@qq.com's avatar
dragondean@qq.com committed
39
        <el-form-item :label="$t('始发地')" prop="startCityId">
wanglianghe's avatar
wanglianghe committed
40
          <el-select v-model="queryParams.startCityId" clearable>
41
            <el-option v-for="city in startCityList" :key="city.id" :label="$l(city, 'title')" :value="city.id" />
42
          </el-select>
43
        </el-form-item>
wanglianghe's avatar
wanglianghe committed
44

dragondean@qq.com's avatar
dragondean@qq.com committed
45
      <el-form-item :label="$t('目的地')" prop="destCityId">
wanglianghe's avatar
wanglianghe committed
46
        <el-select v-model="queryParams.destCityId" clearable>
47
          <el-option v-for="city in destCityList" :key="city.id" :label="$l(city, 'title')" :value="city.id" />
wanglianghe's avatar
wanglianghe committed
48
        </el-select>
49 50
      </el-form-item>

dragondean@qq.com's avatar
dragondean@qq.com committed
51
      <el-form-item :label="$t('上架状态')" prop="auditStatus">
dragondean@qq.com's avatar
dragondean@qq.com committed
52
          <dict-selector :type="DICT_TYPE.ECW_PRICE_AUDIT_STATUS" v-model="queryParams.auditStatus" clearable/>
53
      </el-form-item>
dragondean@qq.com's avatar
dragondean@qq.com committed
54
      <el-form-item :label="$t('状态')" prop="combStatus">
55 56 57
        <el-select v-model="queryParams.combStatus" :placeholder="$t('请选择状态')" clearable>
          <el-option :label="$t('未设置价格')" value="setPrice_1"></el-option>
          <el-option :label="$t('黑名单')" value="blacklist_1"></el-option>
dragondean@qq.com's avatar
dragondean@qq.com committed
58
        </el-select>
59
      </el-form-item>
60 61


wanglianghe's avatar
wanglianghe committed
62
      <el-form-item>
dragondean@qq.com's avatar
dragondean@qq.com committed
63 64
        <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
65 66 67 68 69
      </el-form-item>
    </el-form>

    <!-- 操作工具栏 -->
    <el-row :gutter="10" class="mb8">
70 71
      <!--全部路线吗没有新增入口,指定商品的路线价格才有添加路线-->
      <el-col :span="1.5" v-if="$route.query.product_id">
dragondean@qq.com's avatar
dragondean@qq.com committed
72
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['ecw:product-price:create']">{{$t('新建价格')}}</el-button>
73 74
      </el-col>
      <el-col :span="1.5">
75
        <!--未指定商品-->
76 77 78
        <el-button  v-if="!$route.query.product_id" type="primary" v-hasPermi="['ecw:product-price:batch_update']" size="mini" @click="handleBatchEdit">{{$t('批量设置价格')}}</el-button>
        <el-button  v-if="!$route.query.product_id" type="primary" v-hasPermi="['ecw:product-price:bartch_black']" size="mini" @click="batchBlock" :disabled="multiple">{{$t('批量加入黑名单')}}</el-button>
        <el-button  v-if="!$route.query.product_id" type="primary" v-hasPermi="['ecw:product-price:batch_down']" size="mini" @click="batchOff" :disabled="multiple">{{$t('批量下架')}}</el-button>
79

80
        <el-button v-if="!$route.query.product_id" type="warning" v-hasPermi="['ecw:product-price:export']"  @click="handleExport" :loading="exportLoading" >{{$t('导出')}}</el-button>
wanglianghe's avatar
wanglianghe committed
81

82
        <!--指定商品-->
83
        <el-button v-if="$route.query.product_id" type="primary" v-hasPermi="['ecw:product-price:single_product']" @click="batchSetSingleProductPrice">{{$t('批量设置单个商品的路线')}}</el-button>
wanglianghe's avatar
wanglianghe committed
84
      </el-col>
wanglianghe's avatar
wanglianghe committed
85
      <!-- <el-col :span="1.5">
wanglianghe's avatar
wanglianghe committed
86
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
Marcus's avatar
Marcus committed
87
                   v-hasPermi="['ecw:product-price:export']">{{ $t('导出') }}</el-button>
wanglianghe's avatar
wanglianghe committed
88
      </el-col> -->
wanglianghe's avatar
wanglianghe committed
89 90 91 92
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 列表 -->
93 94
    <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"></el-table-column>
dragondean@qq.com's avatar
dragondean@qq.com committed
95
      <el-table-column :label="$t('序号')" prop="id" width="50" />
wanglianghe's avatar
wanglianghe committed
96

dragondean@qq.com's avatar
dragondean@qq.com committed
97
      <el-table-column :label="$t('商品编码')" align="center" prop="productCode" >
98
        <template slot-scope="{row}">
dragondean@qq.com's avatar
dragondean@qq.com committed
99
            <el-link type="primary" @click.native="handleUpdate(row)">
dragondean@qq.com's avatar
dragondean@qq.com committed
100
              {{ row.productDO ? row.productDO.productCode : $t('无productDO字段') }}
101
            </el-link>
102 103 104
        </template>
      </el-table-column>

dragondean@qq.com's avatar
dragondean@qq.com committed
105
      <el-table-column :label="$t('海关编码')" align="center" prop="customsCode">
106
        <template slot-scope="{row}">
107
            <div>
dragondean@qq.com's avatar
dragondean@qq.com committed
108
              {{ row.productDO ? row.productDO.customsCode : $t('无productDO字段') }}
109 110 111 112
            </div>
        </template>
      </el-table-column>

dragondean@qq.com's avatar
dragondean@qq.com committed
113
      <el-table-column :label="$t('商品类型')" align="center" prop="typeId">
114
        <template slot-scope="{row}">
dragondean@qq.com's avatar
dragondean@qq.com committed
115
          <span>{{ row.productDO ? getTypeName(row.productDO.typeId) : $t('无productDO字段') }}</span>
116 117 118
        </template>
      </el-table-column>

dragondean@qq.com's avatar
dragondean@qq.com committed
119
      <el-table-column :label="$t('商品名称')" align="center" prop="productName">
120
        <template slot-scope="{row}">
dragondean@qq.com's avatar
dragondean@qq.com committed
121
            <el-link type="primary" @click.native="handleUpdate(row)">
dragondean@qq.com's avatar
dragondean@qq.com committed
122
              {{ row.productDO ? row.productDO.titleZh + '/' + row.productDO.titleEn : $t('无productDO字段') }}
123
            </el-link>
124 125 126
        </template>
      </el-table-column>

dragondean@qq.com's avatar
dragondean@qq.com committed
127
      <el-table-column prop="tansportType" :label="$t('运输方式')" align="center" width="100">
wanglianghe's avatar
wanglianghe committed
128 129 130 131 132 133
          <template slot-scope="scope">
            <div>
              {{ transportName(scope.row.warehouseLineDO.transportType) }}
            </div>
          </template>
      </el-table-column>
dragondean@qq.com's avatar
dragondean@qq.com committed
134
      <el-table-column prop="tansportType" :label="$t('出货渠道')" align="center" width="100">
135 136 137 138 139 140
          <template slot-scope="{row}">
            <div>
              {{ channelName(row.shippingChannelId) }}
            </div>
          </template>
      </el-table-column>
dragondean@qq.com's avatar
dragondean@qq.com committed
141
      <el-table-column prop="startDestTitle" :label="$t('始发地') + '/' + $t('目的地')" align="center">
wanglianghe's avatar
wanglianghe committed
142 143 144 145 146 147 148 149 150
          <template slot-scope="scope">
            <div>
              {{ scope.row.warehouseLineDO.startTitleZh }}
              <br />
              {{ scope.row.warehouseLineDO.destTitleZh }}
            </div>
          </template>
      </el-table-column>

dragondean@qq.com's avatar
dragondean@qq.com committed
151
      <el-table-column prop="price" :label="$t('价格')" align="center">
wanglianghe's avatar
wanglianghe committed
152
          <template slot-scope="scope">
dragondean@qq.com's avatar
dragondean@qq.com committed
153 154 155 156 157 158 159 160 161
            <template v-if="scope.row.stepPrice == 1">
              {{$t("第{no}阶梯({start}~{end}{weightUnit}", {
                no: 1,
                start: scope.row.priceStepList[0].startNum,
                end: scope.row.priceStepList[0].endNum,
                weightUnit:  getUnitTitle(scope.row.priceStepList[0].weightUnit),
              })}}<br/>

              <div v-if="scope.row.priceType == 0">
162
                {{$t('运费')}}:{{ getCurrencySymbol(scope.row.priceStepList[0].transportPriceUnit) + scope.row.priceStepList[0].transportPrice}}&nbsp;
dragondean@qq.com's avatar
dragondean@qq.com committed
163 164
                {{ getCurrencyTitle(scope.row.priceStepList[0].transportPriceUnit) + '/' + getUnitTitle(scope.row.priceStepList[0].transportVolumeUnit)}}
                <br />
165
                {{$t('清关费')}}:{{ getCurrencySymbol(scope.row.priceStepList[0].clearancePriceUnit) + scope.row.priceStepList[0].clearancePrice}}&nbsp;
dragondean@qq.com's avatar
dragondean@qq.com committed
166 167 168
                {{ getCurrencyTitle(scope.row.priceStepList[0].clearancePriceUnit) + '/' + getUnitTitle(scope.row.priceStepList[0].clearanceVolumeUnit)}}
              </div>
              <div v-if="scope.row.priceType == 1">
169
                {{$t('全包价')}}:{{ getCurrencySymbol(scope.row.priceStepList[0].allPriceUnit) + scope.row.priceStepList[0].allPrice}}&nbsp;
dragondean@qq.com's avatar
dragondean@qq.com committed
170 171 172 173 174
                {{ getCurrencyTitle(scope.row.priceStepList[0].allPriceUnit) + '/' + getUnitTitle(scope.row.priceStepList[0].allVolumeUnit)}}
              </div>
            </template>
            <template v-else>
              <div v-if="scope.row.priceType == 0">
175
                {{$t('运费')}}:{{ getCurrencySymbol(scope.row.transportPriceUnit) + scope.row.transportPrice}}&nbsp;
dragondean@qq.com's avatar
dragondean@qq.com committed
176 177
                {{ getCurrencyTitle(scope.row.transportPriceUnit) + '/' + getUnitTitle(scope.row.transportVolumeUnit)}}
                <br />
178
                {{$t('清关费')}}:{{ getCurrencySymbol(scope.row.clearancePriceUnit) + scope.row.clearancePrice}}&nbsp;
dragondean@qq.com's avatar
dragondean@qq.com committed
179 180 181
                {{ getCurrencyTitle(scope.row.clearancePriceUnit) + '/' + getUnitTitle(scope.row.clearanceVolumeUnit)}}
              </div>
              <div v-if="scope.row.priceType == 1">
182
                {{$t('全包价')}}:{{ getCurrencySymbol(scope.row.allPriceUnit) + scope.row.allPrice}}&nbsp;
dragondean@qq.com's avatar
dragondean@qq.com committed
183 184 185
                {{ getCurrencyTitle(scope.row.allPriceUnit) + '/' + getUnitTitle(scope.row.allVolumeUnit)}}
              </div>
            </template>
186

wanglianghe's avatar
wanglianghe committed
187 188 189
          </template>
      </el-table-column>

dragondean@qq.com's avatar
dragondean@qq.com committed
190
      <el-table-column prop="auditStatus" align="center" :label="$t('状态')" width="120">
wanglianghe's avatar
wanglianghe committed
191
        <template slot-scope="scope">
192 193
          <div>
              {{ statusName(scope.row) }}
dragondean@qq.com's avatar
dragondean@qq.com committed
194
              <span style="color:red" v-if="(scope.row.validateStartDate && scope.row.validateStartDate > Date.now()) || (scope.row.validateEndDate && scope.row.validateEndDate < Date.now())">(已过期)</span>
195
          </div>
wanglianghe's avatar
wanglianghe committed
196 197
        </template>
      </el-table-column>
wanglianghe's avatar
wanglianghe committed
198

dragondean@qq.com's avatar
dragondean@qq.com committed
199
      <el-table-column prop="advanceStatus" :label="$t('预付')" align="center" width="80">
wanglianghe's avatar
wanglianghe committed
200 201
          <template slot-scope="scope">
            <div>
202
              <!-- {{ getAdvanceStatuTitle(scope.row.advanceStatus) }} -->
203
              <dict-tag :type="DICT_TYPE.ECW_PAY_ADVANCE" :value="scope.row.needPay"></dict-tag>
wanglianghe's avatar
wanglianghe committed
204 205 206
            </div>
          </template>
      </el-table-column>
207 208 209 210 211 212 213
      <el-table-column :label="$t('最后修改时间')">
        <template slot-scope="{row}">
          <div>
              {{ row.updateTime|parseTime }}
          </div>
        </template>
      </el-table-column>
dragondean@qq.com's avatar
dragondean@qq.com committed
214
      <el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width" width="140">
wanglianghe's avatar
wanglianghe committed
215
        <template slot-scope="scope">
dragondean@qq.com's avatar
dragondean@qq.com committed
216
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row, true)"
217
                     v-hasPermi="['ecw:product-price:show']">{{$t('查看')}}</el-button>
wanglianghe's avatar
wanglianghe committed
218
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
dragondean@qq.com's avatar
dragondean@qq.com committed
219
                     v-hasPermi="['ecw:product-price:update']">{{$t('编辑')}}</el-button>
220

221
          <el-button size="mini" type="text" icon="el-icon-edit" @click="updateStatus(scope.row, 'blacklist')"
222
            v-hasPermi="['ecw:product-price:black']">{{ scope.row.blacklist == 0 ? $t('加入黑名单') : $t('移除黑名单') }}</el-button>
223
          <el-button size="mini" type="text" icon="el-icon-edit" @click="updateStatus(scope.row, 'auditStatus')"
224
            v-hasPermi="['ecw:product-price:down']">{{scope.row.auditStatus == AuditStatusEnum.PASS ? $t('下架') : $t('上架')}}</el-button>
225
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
226
            v-hasPermi="['ecw:product-price:delete']">{{$t('删除')}}</el-button>
wanglianghe's avatar
wanglianghe committed
227 228 229 230 231 232 233 234 235 236 237
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>

  </div>
</template>

<script>
238
import { createProductPrice, updateProductPrice, deleteProductPrice, getProductPrice, getProductPricePage, exportProductPriceExcel, batchBlock, batchOff } from "@/api/ecw/productPrice";
wanglianghe's avatar
wanglianghe committed
239
import { openedRouterList } from "@/api/ecw/warehouse";
240
import { getTradeCityList } from "@/api/ecw/region";
wanglianghe's avatar
wanglianghe committed
241
import { getProductTypeList } from "@/api/ecw/productType";
242 243
import { getProductAttrList } from "@/api/ecw/productAttr";
import { getDictDatas, DICT_TYPE } from '@/utils/dict'
wanglianghe's avatar
wanglianghe committed
244 245 246
import { getCurrencyList } from '@/api/ecw/currency';
import { getUnitList } from '@/api/ecw/unit';
import { AuditStatusEnum} from '@/utils/constants'
247 248 249
import { getChannelList } from '@/api/ecw/channel';
import DictTag from '@/components/DictTag'
import {arrryToKeyedObjectBy} from '@/utils/index'
250
import { getProduct } from '@/api/ecw/product';
251
import {parseTime} from '@/utils/ruoyi'
wanglianghe's avatar
wanglianghe committed
252
export default {
253
  name: "EcwProductpriceIndex",
254
  filters: {parseTime},
wanglianghe's avatar
wanglianghe committed
255
  components: {
256
    DictTag
wanglianghe's avatar
wanglianghe committed
257 258 259
  },
  data() {
    return {
260 261 262 263 264 265
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
266 267
      //特性列表
      attrList:[],
wanglianghe's avatar
wanglianghe committed
268 269
      typeList: [],
      product: null,
270 271 272
      cityList: [],
      /* startCityList: [],  //始发地城市
      destCityList: [],   //目的地城市 */
wanglianghe's avatar
wanglianghe committed
273 274 275
      routedList: [],     //已开头路线列表
      currecyList: [],    //货币列表
      unitList: [],       //单位列表
276
      channelList:[] , // 渠道
wanglianghe's avatar
wanglianghe committed
277 278 279
      routeParams:{},    //路线搜索条件
      isUpdate: false,   //更新操作

280 281 282
      //货柜位置
      locationList:[],

wanglianghe's avatar
wanglianghe committed
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 产品价格列表
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      dateRangeCreateTime: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        productId: null,
        warehouseLineId: null,
304
        transportType: null,
wanglianghe's avatar
wanglianghe committed
305 306 307 308 309 310
        transportPrice: null,
        transportPriceUnit: null,
        transportVolumeUnit: null,
        clearancePrice: null,
        clearancePriceUnit: null,
        clearanceVolumeUnit: null,
311
        shippingChannelId: null,
wanglianghe's avatar
wanglianghe committed
312 313 314
        status: null,
      },
      // 表单参数
wanglianghe's avatar
wanglianghe committed
315 316 317 318
      form: {
        typeId: null,
        titleZh: null
      },
wanglianghe's avatar
wanglianghe committed
319 320
      // 表单校验
      rules: {
dragondean@qq.com's avatar
dragondean@qq.com committed
321 322 323 324 325 326 327 328 329
        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" }],
wanglianghe's avatar
wanglianghe committed
330 331
      },

332
      lineList: [],
wanglianghe's avatar
wanglianghe committed
333
      transportDatas: getDictDatas(DICT_TYPE.ECW_TRANSPORT_TYPE),
334
      /* advanceStatusDictDatas: getDictDatas(DICT_TYPE.ADVANCE_STATUS), */
wanglianghe's avatar
wanglianghe committed
335
      AuditStatusEnum: AuditStatusEnum,
336
      locationList: getDictDatas(DICT_TYPE.ECW_CONTAINER_LOCATION),
337

wanglianghe's avatar
wanglianghe committed
338 339
    };
  },
wanglianghe's avatar
wanglianghe committed
340 341

  computed: {
342 343 344 345 346 347 348 349
    // 商品名称
    productTitle(){
      if(!this.product){
        return ''
      }
      return this.product.titleZh
    },
    // 渠道用id做键值
350 351 352
    keyedChannel(){
      return arrryToKeyedObjectBy(this.channelList, 'channelId')
    },
353
    // 根据渠道id获取渠道名
354 355 356 357 358
    channelName(){
      return id => {
        return this.keyedChannel[id] ? this.keyedChannel[id].nameZh : null
      }
    },
359
    // 根据类型获取类型名称
360 361 362 363 364
    getTypeName() {
      return typeId => {
        for(let index in this.typeList) {
          let typeItem = this.typeList[index];
          if(typeItem.id == typeId) {
365
            return this.$l(typeItem, 'title');
366 367 368 369
          }
        }
      }
    },
370
    // 根据状态获取状态名称 ,这个应该可以改成字典,目前接口缺少相关数据,待定
371 372
    statusName() {
      return row => {
373 374 375 376 377 378 379 380 381 382 383
        //判断价格是否过期
        let validateStartDate = row.validateStartDate;
        let validateEndDate = row.validateEndDate;
        let notSetPrice = false;
        let nowDate = new Date().getTime();
        if(validateStartDate && validateStartDate > nowDate) {
          notSetPrice = true;
        }
        if(validateEndDate && validateEndDate < nowDate) {
          notSetPrice = true;
        }
384
        let setPriceText = notSetPrice ? '(' + this.$t('已过期') + ')' : '';
dragondean@qq.com's avatar
dragondean@qq.com committed
385 386
        if(row.blacklist) return this.$t('黑名单') //  + setPriceText;
        if(row.auditStatus === AuditStatusEnum.PASS) return this.$t('已上架') // + setPriceText;
387
        return this.$t('已下架') + setPriceText;
388 389 390
      }
    },

391
    // 根据运输方式获取名称
wanglianghe's avatar
wanglianghe committed
392 393
    transportName() {
      return transportType => {
394
        return this.getDictDataLabel(this.DICT_TYPE.ECW_TRANSPORT_TYPE, transportType)
wanglianghe's avatar
wanglianghe committed
395 396
      }
    },
397
    // 显示币种符号
wanglianghe's avatar
wanglianghe committed
398 399 400 401 402 403 404 405 406 407
    getCurrencySymbol() {
      return currencyId => {
        for(let index in this.currecyList) {
          let currecyItem = this.currecyList[index];
          if(currecyItem.id == currencyId) {
            return currecyItem.fuhao;
          }
        }
      }
    },
408
    // 显示币种名称
wanglianghe's avatar
wanglianghe committed
409 410 411 412 413
    getCurrencyTitle() {
      return currencyId => {
        for(let index in this.currecyList) {
          let currecyItem = this.currecyList[index];
          if(currecyItem.id == currencyId) {
414
            return this.$l(currecyItem, 'title');
wanglianghe's avatar
wanglianghe committed
415 416 417 418 419 420 421 422 423 424
          }
        }
      }
    },

    getUnitTitle() {
      return unitId => {
        for(let index in this.unitList) {
          let unitItem = this.unitList[index];
          if(unitItem.id == unitId) {
425
            return this.$l(unitItem, 'title');
wanglianghe's avatar
wanglianghe committed
426 427 428 429 430
          }
        }
      }
    },

431 432 433 434 435 436
    startCityList(){
      return this.cityList.filter(item => item.type == 2 || item.type == 3)
    },
    destCityList(){
      return this.cityList.filter(item => item.type == 1 || item.type == 3)
    },
wanglianghe's avatar
wanglianghe committed
437
  },
wanglianghe's avatar
wanglianghe committed
438
  activated() {
439
    // console.log('activated', Object.assign({}, this.$route.query))
440
    /* this.$set(this.queryParams, 'typeId', +this.$route.query.product_type || null)
441

442 443 444 445 446 447 448 449
    let productId = this.product?.id
    console.log(this.$route.query.product_id, productId, this.$route.query.product_id != productId)
    if(this.$route.query.product_id != productId){
      this.queryParams = {
        pageNo: 1,
        pageSize: 10
      }
    }
450 451
    this.handleQuery()
     */
wanglianghe's avatar
wanglianghe committed
452
  },
453 454
  watch:{
    '$route.query.product_id'(){
455 456 457
      // if(!this.$route.query.product_id){
      //   return this.product = null
      // }
458
      let productId = this.product?.id
459 460 461 462 463 464 465
      if(this.$route.name === 'ProductPrice'){
        if(this.$route.query.product_id != productId){
          this.queryParams = {
            pageNo: 1,
            pageSize: 10,
            productId: this.$route.query.product_id,
          }
466
        }
467 468 469
        getProduct(this.$route.query.product_id).then(res => {
          this.product = res.data
        })
470
        this.getList();
471 472 473
      }
    }
  },
474 475 476
  created() {
    if(this.$route.query.product_type){
      this.$set(this.queryParams, 'typeId', +this.$route.query.product_type);
wanglianghe's avatar
wanglianghe committed
477
    }
478 479
    // 指定产品获取产品信息
    if(this.$route.query.product_id){
dragondean@qq.com's avatar
dragondean@qq.com committed
480
      this.$set(this.queryParams, 'productId', +this.$route.query.product_id);
481 482 483
      getProduct(this.$route.query.product_id).then(res => {
        this.product = res.data
      })
484
    }else{
485 486
      this.getAttrList();
    }
487

488
    //获取城市列表
dragondean@qq.com's avatar
dragondean@qq.com committed
489
    this.getAllCityList()
490
    this.getChannelList()
dragondean@qq.com's avatar
dragondean@qq.com committed
491
    this.getTypeList()
492

wanglianghe's avatar
wanglianghe committed
493 494 495 496
    //获取货币列表
    this.requestCurrencyList();
    //获取单位列表
    this.requestUnitList();
497 498 499 500

    this.$nextTick(() => {
      this.getList();
    })
wanglianghe's avatar
wanglianghe committed
501
  },
wanglianghe's avatar
wanglianghe committed
502 503 504



wanglianghe's avatar
wanglianghe committed
505
  methods: {
506 507 508
    getChannelList(){
      getChannelList().then(res => this.channelList = res.data)
    },
509 510 511 512 513 514 515
    /** 获取产品属性列表 */
    getAttrList() {
      getProductAttrList().then(response => {
          this.attrList = response.data;
      })
    },

wanglianghe's avatar
wanglianghe committed
516 517 518 519 520 521 522 523 524
     /** 获取产品类型列表 */
    getTypeList() {
      getProductTypeList().then(response => {
        this.typeList = response.data;
      })
    },

    /**获取所有城市列表 */
    getAllCityList() {
525 526
      getTradeCityList({}).then(response => {
          this.cityList = response.data;
wanglianghe's avatar
wanglianghe committed
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
      })
    },

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

    /**获取所有货币列表 */
    requestCurrencyList() {
      getCurrencyList().then(response => {
        this.currecyList = response.data;
542
      })
wanglianghe's avatar
wanglianghe committed
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
    },

    /**获取所有单位列表 */
    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(() => {
dragondean@qq.com's avatar
dragondean@qq.com committed
576
        this.$modal.msgSuccess(this.$t("修改成功"));
wanglianghe's avatar
wanglianghe committed
577 578 579 580 581
      }).catch(function() {
        row.auditStatus = row.auditStatus === AuditStatusEnum.PASS ? AuditStatusEnum.NOT_PASS : AuditStatusEnum.PASS;
      });
    },

wanglianghe's avatar
wanglianghe committed
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
    /** 查询列表 */
    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;
      });
    },
    /** 取消按钮 */
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 表单重置 */
    reset() {
      this.form = {
        id: undefined,
        productId: undefined,
        warehouseLineId: undefined,
        transportPrice: undefined,
        transportPriceUnit: undefined,
        transportVolumeUnit: undefined,
        clearancePrice: undefined,
        clearancePriceUnit: undefined,
        clearanceVolumeUnit: undefined,
        status: undefined,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
dragondean@qq.com's avatar
dragondean@qq.com committed
619 620 621 622 623 624
      this.queryParams.setPrice = undefined
      this.queryParams.blacklist = undefined
      if(this.queryParams.combStatus){
        let tmp = this.queryParams.combStatus.split('_')
        this.queryParams[tmp[0]] = tmp[1]
      }
wanglianghe's avatar
wanglianghe committed
625 626 627 628 629 630 631 632 633 634
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRangeCreateTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {
635
      return this.$router.push('../../lineProject/product-price/edit?' + (new URLSearchParams(this.$route.query)).toString())
636

wanglianghe's avatar
wanglianghe committed
637
    },
638
    // 批量修改单个商品的价格(一条或者多条,后者全部路线)
639
    batchSetSingleProductPrice(){
640
        this.$router.push('../../lineProject/product-price/edit?action=batchUpdate&product_id=' + this.$route.query.product_id + '&ids=' + this.ids)
641
    },
642
    // 批量设置路线
643
    handleBatchEdit() {
644
      this.$router.push('../../lineProject/batch-edit')
645
    },
wanglianghe's avatar
wanglianghe committed
646
    /** 修改按钮操作 */
dragondean@qq.com's avatar
dragondean@qq.com committed
647 648 649 650
    handleUpdate(row, readonly) {
      let url = '../../lineProject/product-price/edit?action=update&id=' + row.id
      if(readonly)url += '&readonly=1'
      return this.$router.push(url)
wanglianghe's avatar
wanglianghe committed
651
    },
wanglianghe's avatar
wanglianghe committed
652

653 654 655 656 657 658 659
    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(() => {
dragondean@qq.com's avatar
dragondean@qq.com committed
660
        this.$modal.msgSuccess(this.$t("修改成功"));
661 662 663 664 665 666
      }).catch(function() {
        if(statusType == 'blacklist') {
          row.blacklist = row.blacklist === 1 ? 0 : 1;
        } else {
          row.auditStatus = row.auditStatus === AuditStatusEnum.PASS ? AuditStatusEnum.NOT_PASS : AuditStatusEnum.PASS;
        }
667

668 669 670
      });
    },

671

wanglianghe's avatar
wanglianghe committed
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686
    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);
    },

wanglianghe's avatar
wanglianghe committed
687 688 689 690 691 692
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (!valid) {
          return;
        }
wanglianghe's avatar
wanglianghe committed
693 694

        if(!this.lineList || !this.lineList.length) {
dragondean@qq.com's avatar
dragondean@qq.com committed
695
            this.$message.error(this.$t('请选择线路'));
wanglianghe's avatar
wanglianghe committed
696 697
            return;
        }
698 699
        let lineChannelList = [];
        //TODO  ,lineChannelList实体空运的时候需要传出货渠道ID--shippingChannelId
wanglianghe's avatar
wanglianghe committed
700
        this.lineList.map((item) => {
701
            lineChannelList.push({lineId: item.id});
wanglianghe's avatar
wanglianghe committed
702 703
            return item;
        });
704
        this.form.lineChannelList = lineChannelList;
wanglianghe's avatar
wanglianghe committed
705

wanglianghe's avatar
wanglianghe committed
706 707 708
        // 修改的提交
        if (this.form.id != null) {
          updateProductPrice(this.form).then(response => {
dragondean@qq.com's avatar
dragondean@qq.com committed
709
            this.$modal.msgSuccess(this.$t("修改成功"));
wanglianghe's avatar
wanglianghe committed
710 711 712 713 714 715
            this.open = false;
            this.getList();
          });
          return;
        }
        // 添加的提交
wanglianghe's avatar
wanglianghe committed
716
        this.form.productId = this.product.id;
wanglianghe's avatar
wanglianghe committed
717
        createProductPrice(this.form).then(response => {
dragondean@qq.com's avatar
dragondean@qq.com committed
718
          this.$modal.msgSuccess(this.$t("请求成功"));
wanglianghe's avatar
wanglianghe committed
719 720 721 722 723 724 725 726
          this.open = false;
          this.getList();
        });
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const id = row.id;
dragondean@qq.com's avatar
dragondean@qq.com committed
727
      this.$modal.confirm(this.$t('是否确认删除产品价格编号为{id}的数据项?', {id})).then(function() {
wanglianghe's avatar
wanglianghe committed
728 729 730
          return deleteProductPrice(id);
        }).then(() => {
          this.getList();
dragondean@qq.com's avatar
dragondean@qq.com committed
731
          this.$modal.msgSuccess(this.$t("删除成功"));
wanglianghe's avatar
wanglianghe committed
732 733 734 735 736 737 738 739 740
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
      let params = {...this.queryParams};
      params.pageNo = undefined;
      params.pageSize = undefined;
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
wanglianghe's avatar
wanglianghe committed
741 742
      // c
      this.$modal.confirm(this.$t('是否确认导出所有数据项?')).then(() => {
wanglianghe's avatar
wanglianghe committed
743 744 745
          this.exportLoading = true;
          return exportProductPriceExcel(params);
        }).then(response => {
wanglianghe's avatar
wanglianghe committed
746
          this.$download.excel(response, '路线价格.xlsx');
wanglianghe's avatar
wanglianghe committed
747
          this.exportLoading = false;
wanglianghe's avatar
wanglianghe committed
748 749 750
        }).catch(() => {
          this.exportLoading = false;
        });
751 752 753 754 755 756
    },
    // 表格多选
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
757 758 759
    },
    batchBlock(){
      batchBlock({ids: this.ids.join(',')}).then(res => {
dragondean@qq.com's avatar
dragondean@qq.com committed
760
        this.$message.success(res.msg || this.$t('操作成功'))
761 762 763 764 765
        this.handleQuery()
      })
    },
    batchOff(){
      batchOff({ids: this.ids.join(',')}).then(res => {
dragondean@qq.com's avatar
dragondean@qq.com committed
766
        this.$message.success(res.msg || this.$t('操作成功'))
767 768 769
        this.handleQuery()
      })
    },
770

wanglianghe's avatar
wanglianghe committed
771 772 773
  }
};
</script>
wanglianghe's avatar
wanglianghe committed
774