MrShi
2024-11-19 0c6aa6e556a8771897b9251a296a7a0c15c57c46
company/src/components/business/OperaSolutionsBaseWindow.vue
@@ -87,7 +87,11 @@
                    placeholder="请选择批改提醒时间">
                </el-time-picker>
            </el-form-item>
            <el-button type="primary" @click="add" style="margin-bottom: 10px;">添加工种</el-button>
            <div style="display: flex; align-items: center;">
                <el-button type="primary" @click="add" style="margin-bottom: 10px;">添加工种</el-button>
                <el-button type="primary" @click="impor" style="margin-bottom: 10px;">导入工种</el-button>
                <el-button type="text" @click="exprot">导入模版xls</el-button>
            </div>
            <el-table
                :data="form.worktypeIdList"
                border
@@ -133,6 +137,8 @@
                <RichEditor :richData="form.ortherInfo" :styleEditor="'border: 1px solid #ccc;display: inline-block;'" @getWangedditor="getWangedditor2" :readonly="false"/>
            </el-form-item>
        </el-form>
        <!--    上传工种    -->
        <input type="file" @change="getFile" style="opacity: 0;" ref="upload" accept=".xlsx" />
    </GlobalWindow>
</template>
@@ -140,7 +146,7 @@
  import BaseOpera from '@/components/base/BaseOpera'
  import GlobalWindow from '@/components/common/GlobalWindow'
  import { all } from '@/api/business/insurance'
  import { all as allWorktype } from '@/api/business/worktype'
  import { all as allWorktype, importExcelForSolution } from '@/api/business/worktype'
  import { solutionsBaseId } from '@/api/business/solutionsBase'
  import { pageAll as shopList } from '@/api/business/company'
  import UploadFile from '@/components/common/UploadFile'
@@ -233,6 +239,37 @@
      })
    },
    methods: {
      // 导入工种模板
      getFile(e) {
        const formdate = new FormData()
        formdate.append('file', e.target.files[0])
        formdate.append('insuranceId', this.form.insuranceId)
        importExcelForSolution(formdate)
          .then(res => {
            console.log(res)
            res.forEach(id => {
              if (this.form.worktypeIdList.length === 1 && !this.form.worktypeIdList[0].worktypeId) {
                this.form.worktypeIdList[0].worktypeId = id
              } else {
                this.form.worktypeIdList.push({ worktypeId: id })
              }
            })
          })
          .catch(err => {
            this.$message.error(err.message)
          })
          .finally(() => {
            this.$refs.upload.value = null
          })
      },
      impor() {
        if (!this.form.insuranceId) return this.$message.warning('请先选择企业')
        this.$refs.upload.click()
      },
      // 导出模板
      exprot() {
        window.open(process.env.VUE_APP_TYPEWORK_URL)
      },
      getWangedditor(val){
        this.form.specialAgreement = val;
      },
@@ -349,7 +386,6 @@
                this.form[key] = res[key]
              }
              this.form.correctWarnTime = `${this.form.correctWarnTime}:00`
              console.log(this.form.correctWarnTime)
              if (res.worktypeList) {
                this.form.worktypeIdList = res.worktypeList.map(item => {
                  return {