Blame view

src/views/workflow/components/dialog/clxxDetailDialog.vue 7.16 KB
1
<!--
xiaomiao committed
2
 * @Description:
3
 * @Autor: renchao
4
 * @LastEditTime: 2023-10-24 17:16:18
5
-->
6 7
<template>
  <div class="clmlmx-box">
renchao@pashanhoo.com committed
8
    <lb-table :column="column" :key="key" row-key="bsmSj" ref="listTable" :heightNumSetting="true" :calcHeight="600"
9
      :pagination="false" :data="tableData">
10 11 12
    </lb-table>
    <div class="text-center">
      <el-button @click="$popupCacel">取消</el-button>
13
      <el-button type="primary" @click="handleSubmit" :loading="loading" v-if="formData.ableOperation && tableData.length>0">保存</el-button>
14 15 16 17
    </div>
  </div>
</template>
<script>
18
  import Vue from 'vue'
19
  import Sortable from 'sortablejs'
20
  import store from '@/store/index.js'
21
  import { updateClml } from "@/api/clxx.js";
22 23 24 25 26 27 28 29 30 31 32
  export default {
    props: {
      formData: {
        type: Object,
        default: () => {
          return {}
        }
      }
    },
    data () {
      return {
33
        loading: false,
renchao@pashanhoo.com committed
34
        sortable: null,
35 36 37 38
        column: [
          {
            prop: "isrequired",
            label: "是否必选",
39
            width: "80",
40
            render: (h, scope) => {
41
              if (scope.row.isrequired === "1") {
42 43
                return (
                  <div>
44
                    <span>必选</span>
45 46 47 48 49 50
                  </div>
                );
              }
              else {
                return (
                  <div>
51
                    <span>可选</span>
52
                  </div>
53
                )
54
              }
55
            }
56 57 58
          },
          {
            label: "材料名称",
59 60
            render: (h, scope) => {
              return (
61
                (this.formData.ableOperation && scope.row.sfxjcl == '1') ?
62
                  <el-input value={scope.row.sjmc} onInput={(val) => { scope.row.sjmc = val }}></el-input> : <span>{scope.row.sjmc}</span>
63 64
              )
            }
65 66 67
          },
          {
            label: "材料类型",
68
            width: "110",
69 70
            render: (h, scope) => {
              return (
71 72 73 74 75 76 77 78 79 80 81
                this.formData.ableOperation ?
                  <el-select value={scope.row.sjlx}
                    onChange={(val) => { scope.row.sjlx = val }}>
                    {
                      store.getters.dictData['A40'].map(option => {
                        return (
                          <el-option label={option.dname} value={option.dcode}></el-option>
                        )
                      })
                    }
                  </el-select> : <span>{this.dicStatus(scope.row.sjlx, "A40")}</span>
82 83
              )
            }
84 85 86
          },
          {
            prop: "sjsl",
87 88
            label: "收件数量",
            width: "80",
89 90
            render: (h, scope) => {
              return (
91
                (this.formData.ableOperation) ?
92
                  <el-input value={scope.row.sjsl} onInput={(val) => { scope.row.sjsl = val }}></el-input> : <span>{
93
                    scope.row.sjsl
94
                  }</span>
95 96
              )
            }
97 98
          },
          {
99
            label: "扫描时间",
100
            width: "140",
101
            render: (h, scope) => {
102
              return (
103
                <span>{scope.row.sjsj}</span>
104 105
              )
            }
106 107
          },
          {
108 109
            label: "页数",
            width: "60",
110
            render: (h, scope) => {
111
              if (scope.row.ys && scope.row.ys > 0) {
112 113
                return (
                  <div>
114
                    <span>{scope.row.ys}</span>
115 116 117 118 119 120 121 122 123 124 125 126
                  </div>
                );
              } else {
                return (
                  <div>
                    <span>0</span>
                  </div>
                );
              }
            },
          },
          {
renchao@pashanhoo.com committed
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
            label: "是否新建材料",
            width: "80",
            render: (h, scope) => {
              if (scope.row.sfxjcl && scope.row.sfxjcl == '1') {
                return (
                  <span></span>
                );
              } else {
                return (
                  <span></span>
                );
              }
            },
          },
          {
142
            label: "操作",
143
            width: "100",
144 145
            render: (h, scope) => {
              return (
146 147 148 149 150 151 152 153 154 155
                <el-button
                  type="text"
                  icon="el-icon-delete"
                  disabled={!(scope.row.ys == 0 && scope.row.sfxjcl == '1') || !this.formData.ableOperation}
                  onClick={() => {
                    this.handleDelete(scope.$index, scope.row);
                  }}
                >
                  删除
                </el-button>
156 157 158
              )
            }
          }
159 160 161 162 163
        ],
        key: 0,
        tableData: []
      }
    },
164 165 166
    watch: {
      'formData.data': {
        handler: function (val, oldVal) {
renchao@pashanhoo.com committed
167
          this.tableData = _.cloneDeep(val)
168 169 170 171
        },
        immediate: true,
        deep: true
      }
172
    },
173 174 175
    mounted () {
      this.initSort()
    },
renchao@pashanhoo.com committed
176 177 178 179 180
    beforeDestroy () {
      if (this.sortable) {
        this.sortable.destroy();
      }
    },
181
    methods: {
182
      handleSubmit () {
183
        this.loading = true
renchao@pashanhoo.com committed
184
        store.dispatch('user/reWorkFresh', false)
185
        updateClml(this.tableData, this.formData.bsmSldy, Vue.prototype.$currentRoute.query.bsmSlsq).then(res => {
186 187 188 189 190 191 192 193 194
          this.loading = false
          if (res.code == 200) {
            this.$message({
              message: '保存成功',
              type: 'success'
            })
            this.$popupCacel()
            store.dispatch('user/reWorkFresh', true)
          }
195 196
        }).catch(() => {
          this.loading = false
197
        })
198
      },
yuanbo committed
199 200 201 202 203
      /**
       * @description: 材料目录删除
       * @param {*} index
       * @param {*} row
       */
204 205 206 207 208 209
      handleDelete (index, row) {
        this.$confirm('此操作将永久删除该 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
renchao@pashanhoo.com committed
210
          this.tableData.splice(index, 1);
211 212 213 214 215 216 217
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
      },
218
      initSort () {
renchao@pashanhoo.com committed
219 220 221 222 223 224 225 226 227
        const el = this.$refs.listTable.$el.querySelectorAll('.el-table__body-wrapper > table > tbody')[0]
        this.sortable = Sortable.create(el, {
          ghostClass: 'sortable-ghost',
          setData: function (dataTransfer) {
            dataTransfer.setData('Text', '')
          },
          onEnd: evt => {
            const targetRow = this.tableData.splice(evt.oldIndex, 1)[0];
            this.tableData.splice(evt.newIndex, 0, targetRow);
228 229
          }
        })
230 231 232 233 234 235 236 237 238 239 240 241
      },
      dicStatus (val, code) {
        let data = store.getters.dictData[code],
          name = '暂无'
        if (data) {
          data.map((item) => {
            if (item.dcode == val) {
              name = item.dname
            }
          })
          return name
        }
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
      }
    }
  }
</script>
<style scoped lang='scss'>
  @import "~@/styles/mixin.scss";
  .clmlmx-box {
    margin: 0 auto;
    .title {
      text-align: center;
      height: 60px;
      line-height: 60px;
      border: 1px solid #dfe6ec;
      font-size: 20px;
      background: #81d3f81a;
      margin-bottom: -1px;
    }
  }
xiaomiao committed
260
</style>