Blame view

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