333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<template lang="">
  <div class="page-list-container">
    <!-- 列表数据 -->
    <yrt-data-list :ref="dataListRef" :editor-ref="editorRef" :data-options="dataOptions" :fields.sync="dataListOptions.fields" :buttons="dataListOptions.buttons" :auth-nodes="authNodes" :data-list-selections.sync="dataListSelections" :button-click="buttonClick" :cell-style="cellStyle">
      <template slot="common-column-slot" slot-scope="{row, col}">
        <template v-if="col.prop==dataOptions.linkColumn">
          <el-link type="primary" @click.native="()=>{linkEditor(row[dataOptions.idField], row);}">
            <template v-if="['date', 'datetime'].indexOf(col.dataType)>=0 && col.formatter">
              {{ common.formatDate(row[col.prop], col.formatter) }}
            </template>
            <template v-else-if="['byte', 'int32', 'int64', 'decimal', 'double'].indexOf(col.dataType)>=0 && col.formatter">
              {{ common.formatNumber(row[col.prop], col.formatter) }}
            </template>
            <template v-else>
              {{ row[col.prop] }}
            </template>
          </el-link>
        </template>
 
        <!-- 自定义地址显示 -->
        <template v-else-if="col.prop === 'annex'">
          <el-link v-if="row.annex" type="primary" @click.native="downAttach(row)">下载附件</el-link>
        </template>
 
        <template v-else-if="col.dropdown_Id>0">
          {{ dataList.translateText(col.prop, row[col.prop], col.dropdown_Id) }}
        </template>
 
        <template v-else>
          <template v-if="['date', 'datetime'].indexOf(col.dataType)>=0 && col.formatter">
            {{ common.formatDate(row[col.prop], col.formatter) }}
          </template>
          <template v-else-if="['byte', 'int32', 'int64', 'decimal', 'double'].indexOf(col.dataType)>=0 && col.formatter">
            {{ common.formatNumber(row[col.prop], col.formatter) }}
          </template>
          <template v-else>
            <template v-if="['date', 'datetime'].indexOf(col.dataType)>=0 && col.formatter">
              {{ common.formatDate(row[col.prop], col.formatter) }}
            </template>
            <template v-else-if="['byte', 'int32', 'int64', 'decimal', 'double'].indexOf(col.dataType)>=0 && col.formatter">
              {{ common.formatNumber(row[col.prop], col.formatter) }}
            </template>
            <template v-else>
              {{ row[col.prop] }}
            </template>
          </template>
        </template>
      </template>
    </yrt-data-list>
    <!-- 修改状态 -->
    <el-dialog v-dialogDrag :visible.sync="isSatusDialog" title="更改快递公司" width="500px">
      <el-form :label-width="formLabelWidth">
        <el-form-item label="合同状态">
          <el-select v-model="from.contractSatus" filterable clearable placeholder="请选择合同状态">
            <el-option v-for="(item, index) in options" :key="index" :label="item.name" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="isSatusDialog=false">取 消</el-button>
        <el-button type="primary" @click="updateSatus()">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 编辑器 -->
    <yrt-editor
      :ref="editorRef"
      :data-list-ref="dataListRef"
      v-bind="editorOptions"
      :data-options="dataOptions"
      :action.sync="editorOptions.action"
      :visible.sync="editorOptions.config.visible"
      :detail-button-click="detailButtonClick"
      :auth-nodes="authNodes"
      :cell-style="cellStyle"
      :on-save-before="onSaveBefore" >
 
    </yrt-editor>
 
  </div>
</template>
<script>
import baseLayout from "@/components/common/base-layout.vue";
var moment = require("moment");
export default {
  name: "basicInfo-consignor-base-consignorContract",
  components: {},
  mixins: [baseLayout],
  data() {
    return {
      from: {
        contractSatus: "" // 选中的合同状态
      },
      options: [
        {
          value: "正常",
          label: "正常"
        },
        {
          value: "终止",
          label: "终止"
        },
        {
          value: "暂停",
          label: "暂停"
        }
      ],
      // 状态显示
      isSatusDialog: false,
      // 页面宽度
      formLabelWidth: "120px"
    };
  },
  mounted() {},
  created() {},
  methods: {
    // 设置行颜色
    cellStyle({ row, column, rowIndex, columnIndex }) {
      const effetiveDays = row.effetiveDays; // 剩余有效天数
      const contractDays = row.contractDays; // 合同天数
 
      if (effetiveDays > contractDays / 3 && effetiveDays < contractDays * 2 / 3) {
        // 当剩余有效天数大于合同天数的1/3,小于合同天数的2/3时,背景颜色将提示为橙黄色
        return { "background-color": "#ff9900 !important", color: "#eee" };
      } else if (effetiveDays > 0 && effetiveDays < contractDays / 3) {
        //  当剩余有效天数大于0,小于合同天数的1/3时,背景颜色将提示为红色
        return { "background-color": "#ff0033", color: "#eee" };
      } else if (effetiveDays < 0) {
        // 当剩余有效天数小于0,也就是合同已过期,背景颜色将提示为深红色
        return { "background-color": "#990000", color: "#eee" };
      }
    },
    // 保存前事件
    onSaveBefore(formData) {
      //  var arr = JSON.parse(formData.expandFields);
      // var start = moment(formData.contractStartTime).format("YYYY-MM-DD HH:mm:ss");
      // var end = moment(formData.contractEndTime).format("YYYY-MM-DD HH:mm:ss");
      // formData.contractDays = end.subtract(start, "days");
      var contractDays = "";
      var effetiveDays = "";
 
      var start = moment(formData.contractStartTime);
      var end = moment(formData.contractEndTime);
      var now = moment();
      // 合同天数=合同结束日期-合同开始日期
      contractDays = end.diff(start, "days");
      // 合同天数=合同结束日期-合同开始日期
      effetiveDays = end.diff(now, "days");
 
      this.editor.changeValue("contractDays", contractDays);
      this.editor.changeValue("effetiveDays", effetiveDays);
    },
    // 显示状态页面
    buttonClick(authNode) {
      switch (authNode) {
        case "contractAlter":
          // 显示对话框
          this.isSatusDialog = true;
          return true;
      }
    },
    // 下载附件
    downAttach(row) {
      //   debugger;
      // const url = row.annex;
      // const urls = url.split(",");
      // for (const _url of urls) {
      //   console.log(_url);
      // }
    },
    // 修改状态
    updateSatus() {
      // 获得已选中的ID
      const selectIDs = this.dataListSelections.map((item, index, Array) => {
        return item.contract_Id;
      });
      if (!selectIDs.length) {
        this.$message({
          message: "至少选中一行!",
          type: "warning"
        });
        return;
      } else {
        this.$confirm("检测到未保存的内容,是否在离开页面前保存修改?", "确认信息", {
          distinguishCancelAndClose: true,
          confirmButtonText: "保存",
          cancelButtonText: "放弃修改"
        }).then(() => {
          const url = "/api/basicInfo/base/ConsignorContract/updateSatus";
          const params = {
            selectIDs: selectIDs,
            contractSatus: this.from.contractSatus
          };
          const ref = this.dataList;
          var callback = res => {
            this.common.showMsg(res);
            if (res.result) {
              this.isSatusDialog = false;
              ref.loadData();
            }
          };
          this.common.ajax(url, params, callback, ref);
        });
      }
    }
  }
};
</script>