From 037a7112a2bc9e38bb2f398ff5ca740ac01a8fb2 Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期四, 20 二月 2025 10:21:05 +0800 Subject: [PATCH] 检验任务搬迁30% --- src/components/Table/value-table.vue | 2531 ++++++++++++++++++++++++++++++++++------------------------ 1 files changed, 1,496 insertions(+), 1,035 deletions(-) diff --git a/src/components/Table/value-table.vue b/src/components/Table/value-table.vue index 0998661..3647f3c 100644 --- a/src/components/Table/value-table.vue +++ b/src/components/Table/value-table.vue @@ -1,320 +1,666 @@ <style scoped> - .value-table { - width: 100%; - height: 100%; - overflow-y: auto; - } +.value-table { + width: 100%; + height: 100%; + overflow-y: auto; +} - .table { - width: 100%; - height: calc(100% - 42px); - } +.table { + width: 100%; + height: calc(100% - 42px); +} - .page { - width: 100%; - height: 30px; - text-align: right; - margin-top: 10px; - } +.page { + width: 100%; + height: 30px; + text-align: right; + margin-top: 10px; +} - .down-left { - width: 50%; - display: flex; - align-items: center; - justify-content: center; - } +.down-left { + width: 50%; + display: flex; + align-items: center; + justify-content: center; +} - .down-right { - width: 50%; - display: flex; - align-items: center; - justify-content: center; - } +.down-right { + width: 50%; + display: flex; + align-items: center; + justify-content: center; +} - .body { - overflow-x: hidden; - } +.body { + overflow-x: hidden; +} - .handleBtn { - border: none; - padding: 0; - color: #409EFF; - background: transparent; - } +.handleBtn { + border: none; + padding: 0; + color: #409eff; + background: transparent; +} - .handleBtn:hover { - background: transparent; - } +.handleBtn:hover { + background: transparent; +} - .handleBtn.is-disabled { - color: #C0C4CC; - } - .red{ - color: red !important; - } - >>>.el-loading-parent--relative { - z-index: 1 !important; - } - >>> .el-table__body-wrapper::-webkit-scrollbar { - height: 14px; /* 璁剧疆婊氬姩鏉″搴� */ - } +.handleBtn.is-disabled { + color: #c0c4cc; +} +.red { + color: red !important; +} +>>> .el-loading-parent--relative { + z-index: 1 !important; +} +>>> .el-table__body-wrapper::-webkit-scrollbar { + height: 14px; /* 璁剧疆婊氬姩鏉″搴� */ +} </style> <style> - /* .value-table .highlight-warning-row-border td { +/* .value-table .highlight-warning-row-border td { border-top: 2px solid #ffcd29; border-bottom: 2px solid #ffcd29; } */ - .value-table .highlight-warning-row-border td:first-child { - border-left: 4px solid #ffcd29; - } +.value-table .highlight-warning-row-border td:first-child { + border-left: 4px solid #ffcd29; +} - .value-table .highlight-warning-row-border td:last-child { - border-right: 4px solid #ffcd29; - } +.value-table .highlight-warning-row-border td:last-child { + border-right: 4px solid #ffcd29; +} - /* .value-table .highlight-danger-row-border td { +/* .value-table .highlight-danger-row-border td { border-top: 2px solid red; border-bottom: 2px solid red; } */ - .value-table .highlight-danger-row-border td:first-child { - border-left: 4px solid #f56c6c; - } +.value-table .highlight-danger-row-border td:first-child { + border-left: 4px solid #f56c6c; +} - .value-table .highlight-danger-row-border td:last-child { - border-right: 4px solid #f56c6c; - } +.value-table .highlight-danger-row-border td:last-child { + border-right: 4px solid #f56c6c; +} - .value-table .el-upload { - width: 100%; - } +.value-table .el-upload { + width: 100%; +} - .value-table .el-upload-dragger { - width: 100%; - } +.value-table .el-upload-dragger { + width: 100%; +} - .value-table .handleBtn.is-disabled .el-upload:focus { - color: #C0C4CC !important; - } +.value-table .handleBtn.is-disabled .el-upload:focus { + color: #c0c4cc !important; +} - .value-table .avatar-uploader .el-upload { - height: 80px; - display: flex; - align-items: center; - justify-content: center; - } - .el-table__empty-text{ - text-align: left; - width: 100%; - display: inline-block; - margin-left: 200px; - } - +.value-table .avatar-uploader .el-upload { + height: 80px; + display: flex; + align-items: center; + justify-content: center; +} +.el-table__empty-text { + text-align: left; + width: 100%; + display: inline-block; + margin-left: 200px; +} </style> <template> <div class="value-table"> - <div :style="data.isPage!=undefined&&data.isPage!=true?'height:100%':''" class="table"> - <el-table :key="specialKey" ref="eltable" v-loading="loading" :current-row-key="data.currentId" :data="tableData" :highlight-current-row="data.highlight===undefined||data.highlight" - :row-class-name="tableRowClassName" :row-key="record=>record[rowKey]" :show-summary="data.countFleid!=undefined && data.countFleid.length > 0" :span-method="spanMethod" + <div + :style=" + data.isPage != undefined && data.isPage != true ? 'height:100%' : '' + " + class="table" + > + <el-table + :key="specialKey" + ref="eltable" + v-loading="loading" + :current-row-key="data.currentId" + :data="tableData" + :highlight-current-row="data.highlight === undefined || data.highlight" + :row-class-name="tableRowClassName" + :row-key="(record) => record[rowKey]" + :show-summary=" + data.countFleid != undefined && data.countFleid.length > 0 + " + :span-method="spanMethod" :summary-method="getSummaries" - height="100%" style="width: 100%;" tooltip-effect="dark" - @select="select" @selection-change="selectChange" - @sort-change="sortChange" @row-click="rowClick"> - <el-table-column v-if="data.showSelect" :key="Math.random()" :width="selectionWidth" type="selection"> + height="100%" + style="width: 100%" + tooltip-effect="dark" + @select="select" + @selection-change="selectChange" + @sort-change="sortChange" + @row-click="rowClick" + > + <el-table-column + v-if="data.showSelect" + :key="Math.random()" + :width="selectionWidth" + type="selection" + > </el-table-column> - <el-table-column v-if="data.isIndex" :key="Math.random()" :width="selectionWidth" align="center" label="搴忓彿" type="index"> + <el-table-column + v-if="data.isIndex" + :key="Math.random()" + :width="selectionWidth" + align="center" + label="搴忓彿" + type="index" + > </el-table-column> - <el-table-column v-for="(a, ai) in tableHead" v-if="!data.headNoShow||(data.headNoShow&&data.headNoShow.length==0)||(data.headNoShow&&data.headNoShow.length>0&&!data.headNoShow.find(d=>d==a.label))" :key="ai+'bbbbb'" :isColumnWidth="isColumnWidth" :isShowZero="isShowZero" - :label="a.value" :min-width="columnMinWidth" :prop="a.label" :sortable="a.sort === 'custom' ? 'custom' : false" show-overflow-tooltip> + <el-table-column + v-for="(a, ai) in tableHead" + v-if=" + !data.headNoShow || + (data.headNoShow && data.headNoShow.length == 0) || + (data.headNoShow && + data.headNoShow.length > 0 && + !data.headNoShow.find((d) => d == a.label)) + " + :key="ai + 'bbbbb'" + :isColumnWidth="isColumnWidth" + :isShowZero="isShowZero" + :label="a.value" + :min-width="columnMinWidth" + :prop="a.label" + :sortable="a.sort === 'custom' ? 'custom' : false" + show-overflow-tooltip + > <template slot-scope="scope"> <div v-if="showType(a.label, data.tagField) != null"> - <template v-if="typeof(scope.row[a.label]) == 'object'"> + <template v-if="typeof scope.row[a.label] == 'object'"> <template v-for="(param, i) in scope.row[a.label]"> - <el-tag v-for="(b, bi) in data.tagField[a.label].select" v-if="b.value == param" :key="bi+'cccc'" - :type="b.type" size="medium" style="margin-right: 5px;">{{b.label}}</el-tag> + <el-tag + v-for="(b, bi) in data.tagField[a.label].select" + v-if="b.value == param" + :key="bi + 'cccc'" + :type="b.type" + size="medium" + style="margin-right: 5px" + >{{ b.label }}</el-tag + > </template> </template> <template v-else> - <el-tag v-for="(b, bi) in data.tagField[a.label].select" v-show="b.value == scope.row[a.label]" :key="bi+'ddddd'" - :type="b.type" size="medium">{{b.label}}</el-tag> + <el-tag + v-for="(b, bi) in data.tagField[a.label].select" + v-show="b.value == scope.row[a.label]" + :key="bi + 'ddddd'" + :type="b.type" + size="medium" + >{{ b.label }}</el-tag + > </template> </div> <!-- 鍙搷浣滆杩涜鐐瑰嚮浜嬩欢 --> - <span v-else-if="data.linkEvent&&showLink(a.label, data.linkEvent)" style="color:#409EFF;cursor: pointer;" - @click="handleLinkEvent(scope.row,data.linkEvent[a.label])">{{scope.row[a.label]}}</span> - <img v-else-if="showUpload(a.label)&&scope.row[a.label]" :src="javaApi+'/img/'+scope.row[a.label]" - alt="" style="width: 40px;height: 40px;margin-top: 10px;"> - <span v-else :class="{red:getRedColor(a.label,scope.row)}" >{{scope.row[a.label]}}</span> + <span + v-else-if="data.linkEvent && showLink(a.label, data.linkEvent)" + style="color: #409eff; cursor: pointer" + @click="handleLinkEvent(scope.row, data.linkEvent[a.label])" + >{{ scope.row[a.label] }}</span + > + <img + v-else-if="showUpload(a.label) && scope.row[a.label]" + :src="javaApi + '/img/' + scope.row[a.label]" + alt="" + style="width: 40px; height: 40px; margin-top: 10px" + /> + <span v-else :class="{ red: getRedColor(a.label, scope.row) }">{{ + scope.row[a.label] + }}</span> </template> </el-table-column> - <el-table-column v-if="data.do.length > 0" :width="getWidth()" align="center" fixed="right" label="鎿嶄綔"> + <el-table-column + v-if="data.do.length > 0" + :width="getWidth()" + align="center" + fixed="right" + label="鎿嶄綔" + > <template slot-scope="scope"> - <el-button v-for="(a, ai) in data.do" :key="ai - +'qqqq'" :disabled="a.disabFun ? a.disabFun(scope.row,scope.$index) : false" - :type="a.type" class="handleBtn" - @click="main(scope.row, a)"> - <span v-if="a.type!='upload'">{{a.font}}</span> - <el-upload v-else ref='upload' - :accept='a.uploadConfig.accept' :action="javaApi+a.uploadConfig.url+'?id='+ (a.uploadConfig.uploadIdFun ? a.uploadConfig.uploadIdFun(scope.row) : scope.row.id)" - :disabled="a.disabFun ? a.disabFun(scope.row,scope.$index) : false" :headers="token" :on-error="onError" :on-success="handleSuccessUp" :show-file-list="false" - name="file" style="background: transparent;"> - <span>{{a.font}}</span> + <el-button + v-for="(a, ai) in data.do" + :key="ai + 'qqqq'" + :disabled=" + a.disabFun ? a.disabFun(scope.row, scope.$index) : false + " + :type="a.type" + class="handleBtn" + @click="main(scope.row, a)" + > + <span v-if="a.type != 'upload'">{{ a.font }}</span> + <el-upload + v-else + ref="upload" + :accept="a.uploadConfig.accept" + :action=" + javaApi + + a.uploadConfig.url + + '?id=' + + (a.uploadConfig.uploadIdFun + ? a.uploadConfig.uploadIdFun(scope.row) + : scope.row.id) + " + :disabled=" + a.disabFun ? a.disabFun(scope.row, scope.$index) : false + " + :headers="token" + :on-error="onError" + :on-success="handleSuccessUp" + :show-file-list="false" + name="file" + style="background: transparent" + > + <span>{{ a.font }}</span> </el-upload> </el-button> </template> </el-table-column> </el-table> </div> - <div v-if="data.isPage==undefined||data.isPage" class="page"> - <el-pagination :current-page="page.current" :page-size="page.size" :page-sizes="[10, 20, 30, 50, 100]" - :total="total" layout="total, sizes, prev, pager, next, jumper" @size-change="sizeChange" - @current-change="currentChange"> + <div v-if="data.isPage == undefined || data.isPage" class="page"> + <el-pagination + :current-page="page.current" + :page-size="page.size" + :page-sizes="[10, 20, 30, 50, 100]" + :total="total" + layout="total, sizes, prev, pager, next, jumper" + @size-change="sizeChange" + @current-change="currentChange" + > </el-pagination> </div> - <el-dialog :close-on-click-modal="false" :visible.sync="upDia" - :width="data.row==1?'500px':540+data.row * 200 + 'px'" - append-to-body title="缂栬緫"> - <div class="body" style="max-height: 600px;overflow-y: auto;padding: 5px 10px 5px 0;"> + <el-dialog + :close-on-click-modal="false" + :visible.sync="upDia" + :width="data.row == 1 ? '500px' : 540 + data.row * 200 + 'px'" + append-to-body + title="缂栬緫" + > + <div + class="body" + style="max-height: 600px; overflow-y: auto; padding: 5px 10px 5px 0" + > <div v-if="data.row > 1"> - <div v-for="(a, ai) in upHead" :key="ai+'ffff'" style="line-height: 50px;"> - <el-col :offset="1" :span="6/data.row" style="text-align: right;"> - <span v-if="showUpReq(a.label)" class="required-span">* </span>{{a.value}}锛� + <div + v-for="(a, ai) in upHead" + :key="ai + 'ffff'" + style="line-height: 50px" + > + <el-col :offset="1" :span="6 / data.row" style="text-align: right"> + <span v-if="showUpReq(a.label)" class="required-span">* </span + >{{ a.value }}锛� </el-col> - <el-col :span="16/data.row"> - <el-input v-if="showType(a.label, data.selectField) == null&&!showUpload(a.label)&&!showCascader(a.label)" v-model="upData[a.label]" :disabled="isDisabled(a.label)" :placeholder="`璇疯緭鍏�${a.value}`" + <el-col :span="16 / data.row"> + <el-input + v-if=" + showType(a.label, data.selectField) == null && + !showUpload(a.label) && + !showCascader(a.label) + " + v-model="upData[a.label]" + :disabled="isDisabled(a.label)" + :placeholder="`璇疯緭鍏�${a.value}`" clearable - size="small"></el-input> - <el-select v-if="showType(a.label, data.selectField) != null" v-model="upData[a.label]" :allow-create="data.selectField[a.label].allowCreate" - :default-first-option="data.selectField[a.label].defaultFirstOption" - :disabled="isDisabled(a.label)" - :multiple="data.selectField[a.label].choose" clearable filterable - size="small" style="width: 100%;"> - <el-option v-for="(b, bi) in data.selectField[a.label].select" :key="bi+'eeeee'" :label="b.label" - :value="b.value"> + size="small" + ></el-input> + <el-select + v-if="showType(a.label, data.selectField) != null" + v-model="upData[a.label]" + :allow-create="data.selectField[a.label].allowCreate" + :default-first-option=" + data.selectField[a.label].defaultFirstOption + " + :disabled="isDisabled(a.label)" + :multiple="data.selectField[a.label].choose" + clearable + filterable + size="small" + style="width: 100%" + > + <el-option + v-for="(b, bi) in data.selectField[a.label].select" + :key="bi + 'eeeee'" + :label="b.label" + :value="b.value" + > </el-option> </el-select> - <el-upload v-if="showUpload(a.label)" ref='upload' - :accept='data.addUploadConfig.accept' :action="javaApi+data.addUploadConfig.url" :headers="token" :multiple="false" - :on-error="onError" :on-success="m=>handleSuccessUp(m, a.label)" :show-file-list="false" class="avatar-uploader" + <el-upload + v-if="showUpload(a.label)" + ref="upload" + :accept="data.addUploadConfig.accept" + :action="javaApi + data.addUploadConfig.url" + :headers="token" + :multiple="false" + :on-error="onError" + :on-success="(m) => handleSuccessUp(m, a.label)" + :show-file-list="false" + class="avatar-uploader" name="file" - style="background: transparent;width: 80px;height: 80px;border: 1px solid #DCDFE6;border-radius: 6px;margin: 10px 0;"> - <img v-if="upData[a.label]" :src="javaApi+'/img/'+upData[a.label]" class="avatar" - style="width: 80px;height: 80px;border-radius: 6px;"> + style=" + background: transparent; + width: 80px; + height: 80px; + border: 1px solid #dcdfe6; + border-radius: 6px; + margin: 10px 0; + " + > + <img + v-if="upData[a.label]" + :src="javaApi + '/img/' + upData[a.label]" + class="avatar" + style="width: 80px; height: 80px; border-radius: 6px" + /> <i v-else class="el-icon-plus avatar-uploader-icon"></i> </el-upload> - <el-cascader v-if="showCascader(a.label)" :options="data.cascaderField[a.label].tree" :placeholder="`璇烽�夋嫨${a.value}`" - :props="data.cascaderField.props" :show-all-levels="false" :value="upData[a.label]" - clearable filterable size="small" - style="width: 100%;" @change="m=>handleCascader(m,a.label)"></el-cascader> + <el-cascader + v-if="showCascader(a.label)" + :options="data.cascaderField[a.label].tree" + :placeholder="`璇烽�夋嫨${a.value}`" + :props="data.cascaderField.props" + :show-all-levels="false" + :value="upData[a.label]" + clearable + filterable + size="small" + style="width: 100%" + @change="(m) => handleCascader(m, a.label)" + ></el-cascader> </el-col> </div> </div> <div v-else> - <el-row v-for="(a, ai) in upHead" :key="ai+'ggggg'" style="line-height: 50px;"> - <el-col :span="6" style="text-align: right;"> - <span v-if="showUpReq(a.label)" class="required-span">* </span>{{a.value}}锛� + <el-row + v-for="(a, ai) in upHead" + :key="ai + 'ggggg'" + style="line-height: 50px" + > + <el-col :span="6" style="text-align: right"> + <span v-if="showUpReq(a.label)" class="required-span">* </span + >{{ a.value }}锛� </el-col> <el-col :offset="1" :span="16"> - <el-input v-if="showType(a.label, data.selectField) == null&&!showUpload(a.label)&&!showCascader(a.label)" v-model="upData[a.label]" :disabled="isDisabled(a.label)" :placeholder="`璇疯緭鍏�${a.value}`" + <el-input + v-if=" + showType(a.label, data.selectField) == null && + !showUpload(a.label) && + !showCascader(a.label) + " + v-model="upData[a.label]" + :disabled="isDisabled(a.label)" + :placeholder="`璇疯緭鍏�${a.value}`" clearable - size="small"></el-input> - <el-select v-if="showType(a.label, data.selectField) != null" v-model="upData[a.label]" :disabled="isDisabled(a.label)" - :multiple="data.selectField[a.label].choose" clearable filterable - size="small" style="width: 100%;"> - <el-option v-for="(b, bi) in data.selectField[a.label].select" :key="bi+'fffff'" :label="b.label" - :value="b.value"></el-option> + size="small" + ></el-input> + <el-select + v-if="showType(a.label, data.selectField) != null" + v-model="upData[a.label]" + :disabled="isDisabled(a.label)" + :multiple="data.selectField[a.label].choose" + clearable + filterable + size="small" + style="width: 100%" + > + <el-option + v-for="(b, bi) in data.selectField[a.label].select" + :key="bi + 'fffff'" + :label="b.label" + :value="b.value" + ></el-option> </el-select> - <el-upload v-if="showUpload(a.label)" ref='upload' :accept='data.addUploadConfig.accept' - :action="javaApi+data.addUploadConfig.url" :headers="token" :multiple="false" :on-error="onError" - :on-success="m=>handleSuccessUp(m, a.label)" :show-file-list="false" class="avatar-uploader" name="file" - style="background: transparent;width: 80px;height: 80px;border: 1px solid #DCDFE6;border-radius: 6px;margin: 10px 0;"> - <img v-if="upData[a.label]" :src="javaApi+'/img/'+upData[a.label]" class="avatar" - style="width: 80px;height: 80px;border-radius: 6px;"> + <el-upload + v-if="showUpload(a.label)" + ref="upload" + :accept="data.addUploadConfig.accept" + :action="javaApi + data.addUploadConfig.url" + :headers="token" + :multiple="false" + :on-error="onError" + :on-success="(m) => handleSuccessUp(m, a.label)" + :show-file-list="false" + class="avatar-uploader" + name="file" + style=" + background: transparent; + width: 80px; + height: 80px; + border: 1px solid #dcdfe6; + border-radius: 6px; + margin: 10px 0; + " + > + <img + v-if="upData[a.label]" + :src="javaApi + '/img/' + upData[a.label]" + class="avatar" + style="width: 80px; height: 80px; border-radius: 6px" + /> <i v-else class="el-icon-plus avatar-uploader-icon"></i> </el-upload> - <el-cascader v-if="showCascader(a.label)" :options="data.cascaderField[a.label].tree" :placeholder="`璇烽�夋嫨${a.value}`" - :props="data.cascaderField.props" :show-all-levels="false" :value="upData[a.label]" clearable - filterable size="small" style="width: 100%;" @change="m=>handleCascader(m,a.label)"></el-cascader> + <el-cascader + v-if="showCascader(a.label)" + :options="data.cascaderField[a.label].tree" + :placeholder="`璇烽�夋嫨${a.value}`" + :props="data.cascaderField.props" + :show-all-levels="false" + :value="upData[a.label]" + clearable + filterable + size="small" + style="width: 100%" + @change="(m) => handleCascader(m, a.label)" + ></el-cascader> </el-col> </el-row> </div> </div> <span slot="footer" class="dialog-footer"> <el-button @click="upDia = false">鍙� 娑�</el-button> - <el-button :loading="upLoad" type="primary" @click="saveUpData">纭� 瀹�</el-button> + <el-button :loading="upLoad" type="primary" @click="saveUpData" + >纭� 瀹�</el-button + > </span> </el-dialog> - <el-dialog :close-on-click-modal="false" :visible.sync="addDia" - :width="data.row==1?'500px':540+data.row * 200 + 'px'" - append-to-body title="鏂板"> - <div v-if="addDia" class="body" style="max-height: 550px;overflow-y: auto;padding: 5px 10px 5px 0;"> + <el-dialog + :close-on-click-modal="false" + :visible.sync="addDia" + :width="data.row == 1 ? '500px' : 540 + data.row * 200 + 'px'" + append-to-body + title="鏂板" + > + <div + v-if="addDia" + class="body" + style="max-height: 550px; overflow-y: auto; padding: 5px 10px 5px 0" + > <div v-if="data.row > 1"> - <div v-for="(a, ai) in upHead" :key="ai+'yyyyy'" style="line-height: 50px;"> - <el-col :offset="1" :span="6/data.row" style="text-align: right;"><span v-if="showAddReq(a.label)" - class="required-span">* - </span>{{a.value}}锛�</el-col> - <el-col :span="16/data.row"> - <el-input v-if="showType(a.label, data.selectField) == null&&!showUpload(a.label)&&!showCascader(a.label)" v-model="upData[a.label]" :placeholder="`璇疯緭鍏�${a.value}`" clearable - size="small"></el-input> - <el-select v-if="showType(a.label, data.selectField) != null" v-model="upData[a.label]" :multiple="data.selectField[a.label].choose" - :placeholder="`璇烽�夋嫨${a.value}`" - clearable filterable size="small" style="width: 100%;"> - <el-option v-for="(b, bi) in data.selectField[a.label].select" :key="bi+'hhhh'" :label="b.label" - :value="b.value"></el-option> + <div + v-for="(a, ai) in upHead" + :key="ai + 'yyyyy'" + style="line-height: 50px" + > + <el-col :offset="1" :span="6 / data.row" style="text-align: right" + ><span v-if="showAddReq(a.label)" class="required-span">* </span + >{{ a.value }}锛�</el-col + > + <el-col :span="16 / data.row"> + <el-input + v-if=" + showType(a.label, data.selectField) == null && + !showUpload(a.label) && + !showCascader(a.label) + " + v-model="upData[a.label]" + :placeholder="`璇疯緭鍏�${a.value}`" + clearable + size="small" + ></el-input> + <el-select + v-if="showType(a.label, data.selectField) != null" + v-model="upData[a.label]" + :multiple="data.selectField[a.label].choose" + :placeholder="`璇烽�夋嫨${a.value}`" + clearable + filterable + size="small" + style="width: 100%" + > + <el-option + v-for="(b, bi) in data.selectField[a.label].select" + :key="bi + 'hhhh'" + :label="b.label" + :value="b.value" + ></el-option> </el-select> - <el-upload v-if="showUpload(a.label)" ref='upload' - :accept='data.addUploadConfig.accept' :action="javaApi+data.addUploadConfig.url" :headers="token" :multiple="false" - :on-error="onError" :on-success="m=>handleSuccessUp(m, a.label)" :show-file-list="false" class="avatar-uploader" + <el-upload + v-if="showUpload(a.label)" + ref="upload" + :accept="data.addUploadConfig.accept" + :action="javaApi + data.addUploadConfig.url" + :headers="token" + :multiple="false" + :on-error="onError" + :on-success="(m) => handleSuccessUp(m, a.label)" + :show-file-list="false" + class="avatar-uploader" name="file" - style="background: transparent;width: 80px;height: 80px;border: 1px solid #DCDFE6;border-radius: 6px;margin: 10px 0;"> - <img v-if="upData[a.label]" :src="javaApi+'/img/'+upData[a.label]" class="avatar" - style="width: 80px;height: 80px;border-radius: 6px;"> + style=" + background: transparent; + width: 80px; + height: 80px; + border: 1px solid #dcdfe6; + border-radius: 6px; + margin: 10px 0; + " + > + <img + v-if="upData[a.label]" + :src="javaApi + '/img/' + upData[a.label]" + class="avatar" + style="width: 80px; height: 80px; border-radius: 6px" + /> <i v-else class="el-icon-plus avatar-uploader-icon"></i> </el-upload> - <el-cascader v-if="showCascader(a.label)" :options="data.cascaderField[a.label].tree" :placeholder="`璇烽�夋嫨${a.value}`" - :props="data.cascaderField.props" :show-all-levels="false" clearable filterable - size="small" style="width: 100%;" @change="m=>handleCascader(m,a.label)"></el-cascader> + <el-cascader + v-if="showCascader(a.label)" + :options="data.cascaderField[a.label].tree" + :placeholder="`璇烽�夋嫨${a.value}`" + :props="data.cascaderField.props" + :show-all-levels="false" + clearable + filterable + size="small" + style="width: 100%" + @change="(m) => handleCascader(m, a.label)" + ></el-cascader> </el-col> </div> </div> <div v-else> - <el-row v-for="(a, ai) in upHead" :key="ai+'jjjjj'" style="line-height: 50px;"> - <el-col :span="6" style="text-align: right;"><span v-if="showAddReq(a.label)" class="required-span">* - </span>{{a.value}}锛�</el-col> + <el-row + v-for="(a, ai) in upHead" + :key="ai + 'jjjjj'" + style="line-height: 50px" + > + <el-col :span="6" style="text-align: right" + ><span v-if="showAddReq(a.label)" class="required-span">* </span + >{{ a.value }}锛�</el-col + > <el-col :offset="1" :span="16"> - <el-input v-if="showType(a.label, data.selectField) == null&&!showUpload(a.label)&&!showCascader(a.label)" v-model="upData[a.label]" :placeholder="`璇疯緭鍏�${a.value}`" clearable - size="small"></el-input> - <el-select v-if="showType(a.label, data.selectField) != null" v-model="upData[a.label]" :multiple="data.selectField[a.label].choose" - :placeholder="`璇烽�夋嫨${a.value}`" - clearable size="small" style="width: 100%;"> - <el-option v-for="(b, bi) in data.selectField[a.label].select" :key="bi+'mmmmmm'" :label="b.label" - :value="b.value"></el-option> + <el-input + v-if=" + showType(a.label, data.selectField) == null && + !showUpload(a.label) && + !showCascader(a.label) + " + v-model="upData[a.label]" + :placeholder="`璇疯緭鍏�${a.value}`" + clearable + size="small" + ></el-input> + <el-select + v-if="showType(a.label, data.selectField) != null" + v-model="upData[a.label]" + :multiple="data.selectField[a.label].choose" + :placeholder="`璇烽�夋嫨${a.value}`" + clearable + size="small" + style="width: 100%" + > + <el-option + v-for="(b, bi) in data.selectField[a.label].select" + :key="bi + 'mmmmmm'" + :label="b.label" + :value="b.value" + ></el-option> </el-select> - <el-upload v-if="showUpload(a.label)" ref='upload' - :accept='data.addUploadConfig.accept' :action="javaApi+data.addUploadConfig.url" :headers="token" :multiple="false" - :on-error="onError" :on-success="m=>handleSuccessUp(m, a.label)" :show-file-list="false" class="avatar-uploader" + <el-upload + v-if="showUpload(a.label)" + ref="upload" + :accept="data.addUploadConfig.accept" + :action="javaApi + data.addUploadConfig.url" + :headers="token" + :multiple="false" + :on-error="onError" + :on-success="(m) => handleSuccessUp(m, a.label)" + :show-file-list="false" + class="avatar-uploader" name="file" - style="background: transparent;width: 80px;height: 80px;border: 1px solid #DCDFE6;border-radius: 6px;margin: 10px 0;"> - <img v-if="upData[a.label]" :src="javaApi+'/img/'+upData[a.label]" class="avatar" - style="width: 80px;height: 80px;border-radius: 6px;"> + style=" + background: transparent; + width: 80px; + height: 80px; + border: 1px solid #dcdfe6; + border-radius: 6px; + margin: 10px 0; + " + > + <img + v-if="upData[a.label]" + :src="javaApi + '/img/' + upData[a.label]" + class="avatar" + style="width: 80px; height: 80px; border-radius: 6px" + /> <i v-else class="el-icon-plus avatar-uploader-icon"></i> </el-upload> - <el-cascader v-if="showCascader(a.label)" :options="data.cascaderField[a.label].tree" :placeholder="`璇烽�夋嫨${a.value}`" - :props="data.cascaderField.props" :show-all-levels="false" clearable filterable - size="small" style="width: 100%;" @change="m=>handleCascader(m,a.label)"></el-cascader> + <el-cascader + v-if="showCascader(a.label)" + :options="data.cascaderField[a.label].tree" + :placeholder="`璇烽�夋嫨${a.value}`" + :props="data.cascaderField.props" + :show-all-levels="false" + clearable + filterable + size="small" + style="width: 100%" + @change="(m) => handleCascader(m, a.label)" + ></el-cascader> </el-col> </el-row> </div> </div> <span slot="footer" class="dialog-footer"> <el-button @click="addDia = false">鍙� 娑�</el-button> - <el-button :loading="addLoad" type="primary" @click="saveAddData">纭� 瀹�</el-button> + <el-button :loading="addLoad" type="primary" @click="saveAddData" + >纭� 瀹�</el-button + > </span> </el-dialog> <el-dialog :visible.sync="downDia" title="瀵煎嚭" width="400px"> - <div style="display: flex;width: 100%;height: 100px;"> + <div style="display: flex; width: 100%; height: 100px"> <div class="down-left" @click="downFile(true)"> <el-button>鏈〉瀵煎嚭</el-button> </div> @@ -324,10 +670,22 @@ </div> </el-dialog> <el-dialog :visible.sync="uploadDia" title="鏁版嵁瀵煎叆" width="500px"> - <div style="margin: 0 auto;"> - <el-upload ref="upload" :accept="data.accept===undefined?'.csv':data.accept" :action="javaApi + inputUrl" :auto-upload="false" :data="{param: data.uploadStr}" :file-list="fileList" - :headers="token" :limit="1" :on-change="beforeUpload" :on-error="onError" :on-success="onSuccess" - drag name="file"> + <div style="margin: 0 auto"> + <el-upload + ref="upload" + :accept="data.accept === undefined ? '.csv' : data.accept" + :action="javaApi + inputUrl" + :auto-upload="false" + :data="{ param: data.uploadStr }" + :file-list="fileList" + :headers="token" + :limit="1" + :on-change="beforeUpload" + :on-error="onError" + :on-success="onSuccess" + drag + name="file" + > <i class="el-icon-upload"></i> <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div> </el-upload> @@ -341,323 +699,346 @@ </template> <script> - export default { - props: { - selectionWidth: { - type: String, - default: () => '65' - }, - columnMinWidth: { - type: String, - default: () => '155' - }, - isColumnWidth: { - type: Boolean, - default: () => false - }, - isShowZero: { - type: Boolean, - default: () => false - }, - tableRowClassName: { - type: Function - }, - rowKey: { - type: String, - default: ()=>{ - return 'id' - } - }, - url: { - type: String, - default: () => null - }, - upUrl: { - type: String, - default: () => null - }, - delUrl: { - type: String, - default: () => null - }, - downUrl: { - type: String, - default: () => null - }, - inputUrl: { - type: String, - default: () => null - }, - componentData: { - type: Object, - default: () => { - return { - entity: { - orderBy: { - field: 'id', - order: 'asc' - } - }, - isIndex: false, - showSelect: false, - select: true, - row: 1, - do: [{ - id: 'update', - font: '缂栬緫', - type: 'text', - method: 'doDiy' - }, { - id: 'delete', - font: '鍒犻櫎', - type: 'text', - method: 'doDiy' - }], - doDiy: true, - tagField: [{ - label: 'state', - select: [{ - value: '1', - type: 'success', - label: '鍚敤' - }, { - value: '0', - type: 'danger', - label: '鍋滅敤' - }] - }] - } - } - } +export default { + props: { + selectionWidth: { + type: String, + default: () => "65", }, - data() { - return { - data: { + columnMinWidth: { + type: String, + default: () => "155", + }, + isColumnWidth: { + type: Boolean, + default: () => false, + }, + isShowZero: { + type: Boolean, + default: () => false, + }, + tableRowClassName: { + type: Function, + }, + rowKey: { + type: String, + default: () => { + return "id"; + }, + }, + url: { + type: String, + default: () => null, + }, + upUrl: { + type: String, + default: () => null, + }, + delUrl: { + type: String, + default: () => null, + }, + downUrl: { + type: String, + default: () => null, + }, + inputUrl: { + type: String, + default: () => null, + }, + componentData: { + type: Object, + default: () => { + return { entity: { orderBy: { - field: 'id', - order: 'asc' - } + field: "id", + order: "asc", + }, }, isIndex: false, showSelect: false, select: true, row: 1, - isPage: true, // - do: [{ - font: '鍒犻櫎', - type: 'text' - }], - type: [], - uploadStr: "", - currentId: '', //褰撳墠楂樹寒鐨処D + do: [ + { + id: "update", + font: "缂栬緫", + type: "text", + method: "doDiy", + }, + { + id: "delete", + font: "鍒犻櫎", + type: "text", + method: "doDiy", + }, + ], + doDiy: true, + tagField: [ + { + label: "state", + select: [ + { + value: "1", + type: "success", + label: "鍚敤", + }, + { + value: "0", + type: "danger", + label: "鍋滅敤", + }, + ], + }, + ], + }; + }, + }, + }, + data() { + return { + data: { + entity: { + orderBy: { + field: "id", + order: "asc", + }, }, - tableHead: [], - tableData: [], - multipleSelection: [], - user: {}, - page: { - current: 1, - size: 20, - }, - total: 0, - loading: false, - upDia: false, - upData: {}, - upHead: [], - upLoad: false, - addDia: false, - addUrl: null, - addLoad: false, - dataCopy: {}, - downDia: false, - uploadDia: false, - token: null, - fileList: [], - init: true, - spanList: [ - // { - // arr:[], - // position:0 - // } + isIndex: false, + showSelect: false, + select: true, + row: 1, + isPage: true, // + do: [ + { + font: "鍒犻櫎", + type: "text", + }, ], - specialSpanList: [ - // { - // arr:[], - // position:0 - // } - ], - param: {}, - specialKey:'table-' - } - }, - beforeUpdate() { - this.$nextTick(() => { - this.$refs.eltable.doLayout() - }) - }, - mounted() { - this.data = this.componentData - this.dataCopy = this.HaveJson(this.componentData) - if (this.data.init === undefined || this.data.init === true) { - this.selectList() - } - this.token = { - 'token': sessionStorage.getItem('token') - } - this.specialKey = this.specialKey+Math.random()*100; - }, - methods: { - rowspan(spanArr, position, spanName) { - this.tableData.forEach((item, index) => { - if (index === 0) { + type: [], + uploadStr: "", + currentId: "", //褰撳墠楂樹寒鐨処D + }, + tableHead: [], + tableData: [], + multipleSelection: [], + user: {}, + page: { + current: 1, + size: 20, + }, + total: 0, + loading: false, + upDia: false, + upData: {}, + upHead: [], + upLoad: false, + addDia: false, + addUrl: null, + addLoad: false, + dataCopy: {}, + downDia: false, + uploadDia: false, + token: null, + fileList: [], + init: true, + spanList: [ + // { + // arr:[], + // position:0 + // } + ], + specialSpanList: [ + // { + // arr:[], + // position:0 + // } + ], + param: {}, + specialKey: "table-", + }; + }, + beforeUpdate() { + this.$nextTick(() => { + this.$refs.eltable.doLayout(); + }); + }, + mounted() { + this.data = this.componentData; + this.dataCopy = this.HaveJson(this.componentData); + if (this.data.init === undefined || this.data.init === true) { + this.selectList(); + } + this.token = { + token: sessionStorage.getItem("token"), + }; + this.specialKey = this.specialKey + Math.random() * 100; + }, + methods: { + rowspan(spanArr, position, spanName) { + this.tableData.forEach((item, index) => { + if (index === 0) { + spanArr.push(1); + position = 0; + } else { + if ( + this.tableData[index][spanName] === + this.tableData[index - 1][spanName] + ) { + spanArr[position] += 1; + spanArr.push(0); + } else { spanArr.push(1); - position = 0; - } else { - if ( - this.tableData[index][spanName] === - this.tableData[index - 1][spanName] - ) { - spanArr[position] += 1; - spanArr.push(0); - } else { - spanArr.push(1); - position = index; - } + position = index; } + } + }); + }, + spanMethod({ row, column, rowIndex, columnIndex }) { + // 涓�鑸殑鍚堝苟琛� + if ( + this.data.spanConfig != undefined && + this.data.spanConfig.rows && + this.data.spanConfig.rows.length > 0 + ) { + let i = null; + let obj = this.data.spanConfig.rows.find((item, index) => { + i = index; + return item.index == columnIndex; }); - }, - spanMethod({ - row, - column, - rowIndex, - columnIndex - }) { - // 涓�鑸殑鍚堝苟琛� - if (this.data.spanConfig != undefined && this.data.spanConfig.rows && this.data.spanConfig.rows.length > 0) { - let i = null; - let obj = this.data.spanConfig.rows.find((item, index) => { - i = index; - return item.index == columnIndex - }) - if (obj) { - const _row = this.spanList[i].arr[rowIndex]; - const _col = _row > 0 ? 1 : 0; - return { - rowspan: _row, - colspan: _col, - }; - } + if (obj) { + const _row = this.spanList[i].arr[rowIndex]; + const _col = _row > 0 ? 1 : 0; + return { + rowspan: _row, + colspan: _col, + }; } - // 鐗规畩鐨勫悎骞惰 - if (this.data.spanConfig != undefined && this.data.spanConfig.special && this.data.spanConfig.special.main && - this.data.spanConfig.special.rows && this.data.spanConfig.special.rows.length > 0) { - let i = null; - let obj = this.data.spanConfig.special.rows.find((item, index) => { - i = index; - return item.index == columnIndex - }) - if (obj) { - const _row = this.specialSpanList[i].arr[rowIndex]; - const _col = _row > 0 ? 1 : 0; - return { - rowspan: _row, - colspan: _col, - }; - } + } + // 鐗规畩鐨勫悎骞惰 + if ( + this.data.spanConfig != undefined && + this.data.spanConfig.special && + this.data.spanConfig.special.main && + this.data.spanConfig.special.rows && + this.data.spanConfig.special.rows.length > 0 + ) { + let i = null; + let obj = this.data.spanConfig.special.rows.find((item, index) => { + i = index; + return item.index == columnIndex; + }); + if (obj) { + const _row = this.specialSpanList[i].arr[rowIndex]; + const _col = _row > 0 ? 1 : 0; + return { + rowspan: _row, + colspan: _col, + }; } - }, - selectChange(val) { - if (this.data.select) { - this.multipleSelection = val; + } + }, + selectChange(val) { + if (this.data.select) { + this.multipleSelection = val; + } else { + this.multipleSelection = val[val.length - 1]; + } + if (this.data.selectMethod != undefined) { + if (this.$parent.$el.className.indexOf("el-") == 0) { + this.$parent.$parent[this.data.selectMethod](val); } else { - this.multipleSelection = val[val.length - 1]; + this.$parent[this.data.selectMethod](val); } - if (this.data.selectMethod != undefined) { - if (this.$parent.$el.className.indexOf('el-') == 0) { - this.$parent.$parent[this.data.selectMethod](val) - } else { - this.$parent[this.data.selectMethod](val) + } + }, + select(val, row) { + if (!this.data.select) { + this.$refs["eltable"].clearSelection(); + this.$refs["eltable"].toggleRowSelection(row, true); + } + }, + rowClick(row, column, event) { + if (this.data.select) { + this.$refs["eltable"].toggleRowSelection(row); + } else { + this.$refs["eltable"].clearSelection(); + this.$refs["eltable"].toggleRowSelection(row, true); + } + }, + sizeChange(val) { + this.page.size = val; + this.selectList("page"); + }, + currentChange(val) { + this.page.current = val; + this.selectList("page"); + }, + // 璋冨彇琛ㄦ牸鏌ヨ鎺ュ彛 + selectList(val) { + // console.log('val---', val) + // console.log('this.page---', this.page) + // this.loading = true + if (val === undefined) { + this.page.current = 1; + } + if (val === "lastPage") { + this.page.current = this.page.current - 1; // 渚嬪鍒犻櫎鏈〉鏈�鍚庝竴鏉℃暟鎹紝灏嗗綋鍓嶉〉闈㈠畾涓轰笂涓�椤碉紝闄ょ涓�椤靛 + } + // 涓嶈鍒嗛〉灏卞叏鏌� + if (this.data.isPage != undefined && this.data.isPage != true) { + this.page = { + current: -1, + size: -1, + }; + } + this.$axios + .post( + this.url, + { + page: this.page, + entity: this.data.entity, + }, + { + headers: { + "Content-Type": "application/json", + }, } - } - }, - select(val, row) { - if (!this.data.select) { - this.$refs['eltable'].clearSelection() - this.$refs['eltable'].toggleRowSelection(row, true) - } - }, - rowClick(row, column, event) { - if (this.data.select) { - this.$refs['eltable'].toggleRowSelection(row) - } else { - this.$refs['eltable'].clearSelection() - this.$refs['eltable'].toggleRowSelection(row, true) - } - }, - sizeChange(val) { - this.page.size = val - this.selectList('page') - }, - currentChange(val) { - this.page.current = val - this.selectList('page') - }, - // 璋冨彇琛ㄦ牸鏌ヨ鎺ュ彛 - selectList(val) { - // console.log('val---', val) - // console.log('this.page---', this.page) - // this.loading = true - if(val===undefined){ - this.page.current = 1; - } - if (val === 'lastPage') { - this.page.current = this.page.current - 1 // 渚嬪鍒犻櫎鏈〉鏈�鍚庝竴鏉℃暟鎹紝灏嗗綋鍓嶉〉闈㈠畾涓轰笂涓�椤碉紝闄ょ涓�椤靛 - } - // 涓嶈鍒嗛〉灏卞叏鏌� - if (this.data.isPage != undefined && this.data.isPage != true) { - this.page = { - current: -1, - size: -1, - } - } - this.$axios.post(this.url, { - page: this.page, - entity: this.data.entity - }, { - headers: { - 'Content-Type': 'application/json' - } - }).then(res => { + ) + .then((res) => { if (res.code === 201) { - this.loading = false - return + this.loading = false; + return; } - this.total = res.data.body.total - this.tableHead = res.data.head - this.tableData = res.data.body.records + this.total = res.data.body.total; + this.tableHead = res.data.head; + this.tableData = res.data.body.records; if (this.data.needSort !== undefined) { // 鏍规嵁鐖剁粍浠朵紶鍥炴潵鐨刵eedSort鏁扮粍锛屽垽鏂摢浜涘瓧娈甸渶瑕佹帓搴忓姛鑳� for (var i = 0; i < this.data.needSort.length; i++) { - this.tableHead.forEach(item => { + this.tableHead.forEach((item) => { if (item.label === this.data.needSort[i]) { - item.sort = 'custom' + item.sort = "custom"; } - }) + }); } } if (this.isShowZero) { // 宸ユ椂绠$悊-宸ユ椂缁熻娌℃湁鏃堕棿鐨勫氨灞曠ず0 - this.tableData.map(item => { - Object.keys(item).forEach(val => { - if (item[val] === null && (val.includes('Hours') || val === 'total')) { - item[val] = 0 + this.tableData.map((item) => { + Object.keys(item).forEach((val) => { + if ( + item[val] === null && + (val.includes("Hours") || val === "total") + ) { + item[val] = 0; } - }) - }) + }); + }); } if (this.tableData.length === 0 && this.page.current > 1) { - this.selectList('lastPage') + this.selectList("lastPage"); } // if (this.isColumnWidth) { // this.tableHead.forEach(item => { @@ -684,554 +1065,634 @@ // console.log(JSON.stringify(this.tableHead)+"---------"+JSON.stringify(this.tableData)) for (var a in this.data.selectField) { if (this.data.selectField[a].choose == true) { - this.tableData.map(b => { + this.tableData.map((b) => { try { - b[a] = JSON.parse(b[a]) + b[a] = JSON.parse(b[a]); } catch (e) {} - }) + }); } } // 涓�鑸殑鍚堝苟琛� - if (this.data.spanConfig != undefined && this.data.spanConfig.rows && this.data.spanConfig.rows.length > - 0) { + if ( + this.data.spanConfig != undefined && + this.data.spanConfig.rows && + this.data.spanConfig.rows.length > 0 + ) { this.spanList = []; this.data.spanConfig.rows.forEach((item, index) => { this.spanList.push({ arr: [], - position: 0 - }) - this.rowspan(this.spanList[index].arr, this.spanList[index].position, item.name); - }) + position: 0, + }); + this.rowspan( + this.spanList[index].arr, + this.spanList[index].position, + item.name + ); + }); } // 鐗规畩鐨勫悎骞惰 - if (this.data.spanConfig != undefined && this.data.spanConfig.special && this.data.spanConfig.special - .main && this.data.spanConfig.special.rows && this.data.spanConfig.special.rows.length > 0) { - this.specialSpanList = [] + if ( + this.data.spanConfig != undefined && + this.data.spanConfig.special && + this.data.spanConfig.special.main && + this.data.spanConfig.special.rows && + this.data.spanConfig.special.rows.length > 0 + ) { + this.specialSpanList = []; this.data.spanConfig.special.rows.forEach((item, index) => { this.specialSpanList.push({ arr: [], - position: 0 - }) - this.rowspan(this.specialSpanList[index].arr, this.specialSpanList[index].position, this.data - .spanConfig.special.main); - }) + position: 0, + }); + this.rowspan( + this.specialSpanList[index].arr, + this.specialSpanList[index].position, + this.data.spanConfig.special.main + ); + }); } - this.loading = false - }).catch(e => { - console.log('璇峰埛鏂伴〉闈㈠啀灏濊瘯---', e) - this.loading = false - this.$message.error('璇峰埛鏂伴〉闈㈠啀灏濊瘯') + this.loading = false; }) - }, - sortChange(ob) { - this.data.entity.orderBy = {} - this.data.entity.orderBy.field = ob.prop - if (ob.order == 'ascending') { - this.data.entity.orderBy.order = 'asc' - } else if (ob.order == 'descending') { - this.data.entity.orderBy.order = 'desc' - } else { - if (this.componentData.entity.orderBy != undefined) { - this.data.entity.orderBy = this.HaveJson(this.dataCopy.entity.orderBy) - } - } - this.selectList() - }, - // 灞曠ずtag - showType(val, ob) { - var str = ob[val] - return str == undefined ? null : ob[val].select - }, - // 灞曠ず鎿嶄綔鏍� - showLink(val, ob) { - var str = ob[val] - return str == undefined ? null : ob[val].method - }, - showAddReq(label) { - if (this.data.requiredAdd == undefined) { - return - } - for (var i = 0; i < this.data.requiredAdd.length; i++) { - if (label == this.data.requiredAdd[i]) { - return true - } - } - return false - }, - showUpReq(label) { - if (this.data.requiredUp == undefined) { - return - } - for (var i = 0; i < this.data.requiredUp.length; i++) { - if (label == this.data.requiredUp[i]) { - return true - } - } - return false - }, - showUpload(label) { - if (this.data.addUpload && this.data.addUpload.find(m => m == label)) { - return true; - } else { - return false; - } - }, - showCascader(label) { - if (this.data.cascaderField && this.data.cascaderField[label]) { - return true; - } else { - return false; - } - }, - handleTree(arr, value) { - let label = '' - for (let i = 0; i < arr.length; i++) { - if (arr[i].id == value) { - label = arr[i].name - return label - } else if (arr[i].children) { - label = this.handleTree(arr[i].children, value) - } - } - return label - }, - main(row, val) { - if (val.method == undefined) return - else if (val.method == 'doDiy') { - if (val.id == 'update') { // 缂栬緫鎿嶄綔 - this.upDia = true, - this.upData = this.HaveJson(row) - this.upHead = this.HaveJson(this.tableHead) - this.upHead.forEach((item, index) => { - if (this.data.cascaderField && this.data.cascaderField[item.label]) { - if (this.upData[item.label]) { - this.upData[item.label] = JSON.parse(this.upData[item.label]) - } else { - this.upData[item.label] = [] - } - } - }) - this.upHead = this.upHead.filter(a => a.label != 'createTime' && a.label != 'updateTime') - delete this.upData.orderBy - delete this.upData.createTime - delete this.upData.updateTime - delete this.upData.createUser - delete this.upData.updateUser - val.field.forEach(a => { - if (this.upData[a] === undefined) { - this.upHead.push({ - value: a.split('=')[0], - label: a.split('=')[1] - }) - } else { - delete this.upData[a] - for (var i = 0; i < this.upHead.length; i++) { - if (this.upHead[i].label == a) { - this.upHead.splice(i, 1); - i-- - break - } - } - } - }) - } else if (val.id == 'delete') { // 鍒犻櫎鎿嶄綔 - if (this.delUrl == null) { - this.$message.error('璇风粰鍒犻櫎璇锋眰鍦板潃') - return - } - this.$confirm('鏄惁鍒犻櫎褰撳墠鏁版嵁?', "璀﹀憡", { - confirmButtonText: "纭畾", - cancelButtonText: "鍙栨秷", - type: "warning" - }).then(() => { - this.$axios.post(this.delUrl, { - id: row.id - }).then(res => { - if (res.code === 201) { - return - } - this.$message.success('鍒犻櫎鎴愬姛') - this.selectList('page') - this.$emit('delete') - }).catch(e => { - this.$message.error('鍒犻櫎澶辫触') - }) - }).catch(() => {}) - } - } else if (val.id === 'parent') { - delete row.orderBy - this.$parent.$parent[val.method](row) - } else { - delete row.orderBy - this.$parent[val.method](row) - } - }, - saveUpData() { - if (this.upUrl == null) { - this.$message.error('璇风粰淇敼璇锋眰鍦板潃') - return - } - for (var i = 0; i < this.data.requiredUp.length; i++) { - // 蹇呭~鏍¢獙 - if (this.upData[this.data.requiredUp[i]] === null || this.upData[this.data.requiredUp[i]] === '') { - var list = this.upHead.filter(a => { - if (a.label == this.data.requiredUp[i]) return a - }) - if (list[0].value == undefined) continue - this.$message.error(list[0].value + '鏄繀濉」') - return - } - } - for (var a in this.data.selectField) { - if (this.data.selectField[a].choose == true) { - this.upData[a] = JSON.stringify(this.upData[a]) - } - } - for (var i = 0; i < this.upHead.length; i++) { - if(this.upHead[i].label == 'password'){ - if(this.upData[this.upHead[i].label]){ - const reg2 =/^(?=.*?[a-z])(?=.*?[A-Z])(?=.*?\d)(?=.*?[~!#@$%^*&()_+{}\[\]|\\;:'",<.>\/?])[a-zA-Z\d~!#@$%^*&()_+{}\[\]|\\;:'",<.>\/?]*$/; - if (!reg2.test(this.upData[this.upHead[i].label])) { - this.$message.error('瀵嗙爜蹇呴』鍖呮嫭鏁板瓧銆佸ぇ灏忓啓瀛楁瘝浠ュ強鐗规畩瀛楃') - return - } - } - } - if (this.data.cascaderField && this.data.cascaderField[this.upHead[i].label]) { - if (this.upData[this.upHead[i].label]) { - this.upData[this.upHead[i].label] = JSON.stringify(this.upData[this.upHead[i].label]) - } else { - this.upData[this.upHead[i].label] = '' - } - } - } - this.upLoad = true - this.$axios.post(this.upUrl, this.upData, { - headers: { - 'Content-Type': 'application/json' - } - }).then(res => { - if (res.code === 201) { - this.upLoad = false - return - } - this.$message.success('淇敼鎴愬姛') - this.upDia = false - this.selectList('page') - this.$refs.eltable.doLayout(); - this.upLoad = false - }).catch(e => { - this.$message.error('淇敼澶辫触') - this.upDia = false - this.upLoad = false - }) - }, - // 鎵撳紑鏂板寮规鍥炶皟 - openAddDia(addUrl, param) { - this.addDia = true - this.addUrl = addUrl - this.param = param - this.upData = {} - this.tableHead.forEach((k, v) => { - if (k.label != 'orderBy' && k.label != 'createTime' && k.label != 'updateTime' && k.label != 'createUser' && k.label != 'updateUser') - this.upData[k.label] = null - }) - this.upData = this.HaveJson(this.upData) - this.upHead = this.HaveJson(this.tableHead) - this.upHead = this.upHead.filter(a => a.label != 'createTime' && a.label != 'updateTime') - var val = this.data.do.filter(a => a.id == 'update')[0] - if (val == undefined) { - val = { - field: [] - } - } - val.field.forEach(a => { - if (JSON.stringify(this.upData[a]) === undefined) { - this.upHead.push({ - value: a.split('=')[0], - label: a.split('=')[1] - }) - } else { - delete this.upData[a] - for (var i = 0; i < this.upHead.length; i++) { - if (this.upHead[i].label == a) { - this.upHead.splice(i, 1); - i-- - break - } - } - } - }) - }, - // 鏂板鍥炶皟 - saveAddData() { - if (this.addUrl == null) { - this.$message.error('璇风粰娣诲姞璇锋眰鍦板潃') - return - } - for (var i = 0; i < this.data.requiredAdd.length; i++) { - if (this.upData[this.data.requiredAdd[i]] === null || this.upData[this.data.requiredAdd[i]] === '') { - var list = this.upHead.filter(a => { - if (a.label == this.data.requiredAdd[i]) return a - }) - if (list[0].value == undefined) continue - this.$message.error(list[0].value + '鏄繀濉」') - return - } - } - this.addLoad = true - for (var a in this.data.selectField) { - if (this.data.selectField[a].choose == true) { - this.upData[a] = JSON.stringify(this.upData[a]) - } - } - this.upHead.forEach((item, index) => { - if (this.data.cascaderField && this.data.cascaderField[item.label]) { - if (this.upData[item.label]) { - this.upData[item.label] = JSON.stringify(this.upData[item.label]) - } else { - this.upData[item.label] = '' - } - } - }) - if (this.param !== undefined && this.param !== null) { - for (let i in this.param) { - this.upData[i] = this.param[i] - } - } - this.$axios.post(this.addUrl, this.upData, { - headers: { - 'Content-Type': 'application/json' - } - }).then(res => { - if (res.code === 201) { - this.addLoad = false - return - } - this.$message.success('娣诲姞鎴愬姛') - this.addDia = false - this.selectList('page') - this.addLoad = false - }).catch(e => { - this.addDia = false - this.addLoad = false - }) - }, - openDownDia() { - this.downDia = true - }, - downFile(type) { - if (this.downUrl == null) { - this.$message.error('璇风粰瀵煎嚭璇锋眰鍦板潃') - return - } - var page = this.HaveJson(this.page) - if (!type) { - page.current = 0 - page.size = this.total - } - this.loading = true - this.$axios.post(this.downUrl, { - page: page, - entity: this.data.entity - }, { - headers: { - 'Content-Type': 'application/json' - } - }).then(res => { - if (res.code === 201) { - this.loading = false - return - } - this.downDia = false - this.loading = false - this.$message.success('瀵煎嚭鎴愬姛') - let eleLink = document.createElement('a') - eleLink.style.display = 'none' - eleLink.download = res.data - eleLink.href = this.javaApi + '/outPath/' + res.data - document.body.appendChild(eleLink) - eleLink.click() - document.body.removeChild(eleLink) - }).catch(e => { - console.log(e); - this.loading = false - this.$message.error('璇峰埛鏂伴〉闈㈠啀灏濊瘯') - }) - }, - openUpload() { - if (this.inputUrl == null) { - this.$message.error('璇风粰瀵煎叆璇锋眰鍦板潃') - return - } - this.uploadDia = true - }, - beforeUpload(file, fileList) { - console.log(file.raw.type); - if (file.raw.type != (this.data.inputType===undefined?'text/csv':this.data.inputType)) { - this.$message.error('涓婁紶鏂囦欢鏍煎紡涓嶆纭�'); - this.$refs.upload.clearFiles() - return false; - } - }, - submitUpload() { - if (this.$refs.upload.uploadFiles.length == 0) { - this.$message.error('鏈�夋嫨鏂囦欢') - return - } - this.uploading = true - this.$refs.upload.submit(); - }, - onSuccess(response, file, fileList) { - this.$refs.upload.clearFiles() - this.uploadDia = false - this.uploading = false - if (response.code == 201) { - this.$message.error(response.message) - return - } - this.$message.success('涓婁紶鎴愬姛') - this.selectList() - }, - onError(err, file, fileList) { - this.$message.error('涓婁紶澶辫触') - this.$refs.upload.clearFiles() - this.uploading = false - }, - // 鎿嶄綔鎸夐挳缃伆鍒ゆ柇 - isDisabled(label) { - if (this.data.disabledUp == undefined) { - return - } - for (var i = 0; i < this.data.disabledUp.length; i++) { - if (label == this.data.disabledUp[i]) { - return true - } - } - return false - }, - getSummaries(param) { - const { - columns, - data - } = param; - const sums = []; - columns.forEach((column, index) => { - if (index === 0) { - sums[index] = '鍚堣'; - return; - } - const values = data.map(item => Number(item[column.property])); - if (this.data.countFleid == undefined) { - sums[index] = '' - return - } - if (this.data.countFleid.filter(str => { - return str === column.property - }).length > 0) { - sums[index] = values.reduce((prev, curr) => { - const value = Number(curr); - if (!isNaN(value)) { - return prev + curr; - } else { - return prev; - } - }, 0); - sums[index] += ''; - } else { - sums[index] = ''; - } + .catch((e) => { + console.log("璇峰埛鏂伴〉闈㈠啀灏濊瘯---", e); + this.loading = false; + this.$message.error("璇峰埛鏂伴〉闈㈠啀灏濊瘯"); }); - return sums; - }, - handleLinkEvent(row, val) { - if (val.method == 'doDiy') { - this.main(row, val) - } else { - this.$parent[val.method](row) - } - }, - getWidth() { - let count = 0 - this.data.do.forEach(a => { - count += a.font.length - }) - return count * 15 + 60 + 'px' - }, - handleSuccessUp(response, label) { - if (typeof label === 'string') { - if (response.code == 200) { - this.upData[label] = response.data.url; - } - } else { - if (response.code == 200) { - this.$message.success('涓婁紶鎴愬姛') - this.selectList() - } - } - }, - handleCascader(e, label) { - this.upData[label] = e; - }, - // 鎵归噺鍒犻櫎 - batchDelete() { - if (this.multipleSelection && this.multipleSelection.length > 0) { - this.$confirm('鏄惁鍒犻櫎閫変腑鐨勬暟鎹�?', "璀﹀憡", { - confirmButtonText: "纭畾", - cancelButtonText: "鍙栨秷", - type: "warning" - }).then(() => { - this.$axios.post(this.delUrl, { - ids: JSON.stringify(this.multipleSelection.map(item => item.id)) - }).then(res => { - if (res.code === 201) { - return - } - this.$message.success('鍒犻櫎鎴愬姛') - this.selectList('page') - }).catch(e => { - this.$message.error('鍒犻櫎澶辫触') - }) - }).catch(() => {}) - } else { - this.$message.error('璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁') - } - }, - // 鏃ュ伐鏃剁鐞嗚緟鍔╁伐鏃�--鎵归噺瀹℃牳鍜屾壒鍑� - batchCheck(e) { - if (this.multipleSelection && this.multipleSelection.length > 0) { - const list = JSON.parse(JSON.stringify(this.multipleSelection)) - const state = e === 0 ? '涓嶆壒鍑�' : '宸叉壒鍑�' - let auxiliaryWorkingHoursDays = [] - list.forEach(item => { - delete item.orderBy - item.state = state - auxiliaryWorkingHoursDays.push(item) - }) - this.$axios.post(this.$api.auxiliaryWorkingHoursDay.approve, {auxiliaryWorkingHoursDays: auxiliaryWorkingHoursDays - },{ - headers: { - 'Content-Type': 'application/json' - } - } - ).then(res => { - if (res.code === 201) { - return - } - this.$parent.submitBatchCheckDialog() - this.$message.success('鎿嶄綔鎴愬姛') - }) - } else { - this.$message.error('璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�') - } - }, - getRedColor(label,row){ - if(this.data.cellSpecialStyle&&this.data.cellSpecialStyle.redColorByKey&&label.includes(this.data.cellSpecialStyle.redColorByKey)&&row[(label.replace(this.data.cellSpecialStyle.redColorByKey, ""))]){ - return true - }else{ - return false + }, + sortChange(ob) { + this.data.entity.orderBy = {}; + this.data.entity.orderBy.field = ob.prop; + if (ob.order == "ascending") { + this.data.entity.orderBy.order = "asc"; + } else if (ob.order == "descending") { + this.data.entity.orderBy.order = "desc"; + } else { + if (this.componentData.entity.orderBy != undefined) { + this.data.entity.orderBy = this.HaveJson( + this.dataCopy.entity.orderBy + ); } } - } - } + this.selectList(); + }, + // 灞曠ずtag + showType(val, ob) { + var str = ob[val]; + return str == undefined ? null : ob[val].select; + }, + // 灞曠ず鎿嶄綔鏍� + showLink(val, ob) { + var str = ob[val]; + return str == undefined ? null : ob[val].method; + }, + showAddReq(label) { + if (this.data.requiredAdd == undefined) { + return; + } + for (var i = 0; i < this.data.requiredAdd.length; i++) { + if (label == this.data.requiredAdd[i]) { + return true; + } + } + return false; + }, + showUpReq(label) { + if (this.data.requiredUp == undefined) { + return; + } + for (var i = 0; i < this.data.requiredUp.length; i++) { + if (label == this.data.requiredUp[i]) { + return true; + } + } + return false; + }, + showUpload(label) { + if (this.data.addUpload && this.data.addUpload.find((m) => m == label)) { + return true; + } else { + return false; + } + }, + showCascader(label) { + if (this.data.cascaderField && this.data.cascaderField[label]) { + return true; + } else { + return false; + } + }, + handleTree(arr, value) { + let label = ""; + for (let i = 0; i < arr.length; i++) { + if (arr[i].id == value) { + label = arr[i].name; + return label; + } else if (arr[i].children) { + label = this.handleTree(arr[i].children, value); + } + } + return label; + }, + main(row, val) { + if (val.method == undefined) return; + else if (val.method == "doDiy") { + if (val.id == "update") { + // 缂栬緫鎿嶄綔 + (this.upDia = true), (this.upData = this.HaveJson(row)); + this.upHead = this.HaveJson(this.tableHead); + this.upHead.forEach((item, index) => { + if ( + this.data.cascaderField && + this.data.cascaderField[item.label] + ) { + if (this.upData[item.label]) { + this.upData[item.label] = JSON.parse(this.upData[item.label]); + } else { + this.upData[item.label] = []; + } + } + }); + this.upHead = this.upHead.filter( + (a) => a.label != "createTime" && a.label != "updateTime" + ); + delete this.upData.orderBy; + delete this.upData.createTime; + delete this.upData.updateTime; + delete this.upData.createUser; + delete this.upData.updateUser; + val.field.forEach((a) => { + if (this.upData[a] === undefined) { + this.upHead.push({ + value: a.split("=")[0], + label: a.split("=")[1], + }); + } else { + delete this.upData[a]; + for (var i = 0; i < this.upHead.length; i++) { + if (this.upHead[i].label == a) { + this.upHead.splice(i, 1); + i--; + break; + } + } + } + }); + } else if (val.id == "delete") { + // 鍒犻櫎鎿嶄綔 + if (this.delUrl == null) { + this.$message.error("璇风粰鍒犻櫎璇锋眰鍦板潃"); + return; + } + this.$confirm("鏄惁鍒犻櫎褰撳墠鏁版嵁?", "璀﹀憡", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning", + }) + .then(() => { + this.$axios + .post(this.delUrl, { + id: row.id, + }) + .then((res) => { + if (res.code === 201) { + return; + } + this.$message.success("鍒犻櫎鎴愬姛"); + this.selectList("page"); + this.$emit("delete"); + }) + .catch((e) => { + this.$message.error("鍒犻櫎澶辫触"); + }); + }) + .catch(() => {}); + } + } else if (val.id === "parent") { + delete row.orderBy; + this.$parent.$parent[val.method](row); + } else { + delete row.orderBy; + this.$parent[val.method](row); + } + }, + saveUpData() { + if (this.upUrl == null) { + this.$message.error("璇风粰淇敼璇锋眰鍦板潃"); + return; + } + for (var i = 0; i < this.data.requiredUp.length; i++) { + // 蹇呭~鏍¢獙 + if ( + this.upData[this.data.requiredUp[i]] === null || + this.upData[this.data.requiredUp[i]] === "" + ) { + var list = this.upHead.filter((a) => { + if (a.label == this.data.requiredUp[i]) return a; + }); + if (list[0].value == undefined) continue; + this.$message.error(list[0].value + "鏄繀濉」"); + return; + } + } + for (var a in this.data.selectField) { + if (this.data.selectField[a].choose == true) { + this.upData[a] = JSON.stringify(this.upData[a]); + } + } + for (var i = 0; i < this.upHead.length; i++) { + if (this.upHead[i].label == "password") { + if (this.upData[this.upHead[i].label]) { + const reg2 = + /^(?=.*?[a-z])(?=.*?[A-Z])(?=.*?\d)(?=.*?[~!#@$%^*&()_+{}\[\]|\\;:'",<.>\/?])[a-zA-Z\d~!#@$%^*&()_+{}\[\]|\\;:'",<.>\/?]*$/; + if (!reg2.test(this.upData[this.upHead[i].label])) { + this.$message.error("瀵嗙爜蹇呴』鍖呮嫭鏁板瓧銆佸ぇ灏忓啓瀛楁瘝浠ュ強鐗规畩瀛楃"); + return; + } + } + } + if ( + this.data.cascaderField && + this.data.cascaderField[this.upHead[i].label] + ) { + if (this.upData[this.upHead[i].label]) { + this.upData[this.upHead[i].label] = JSON.stringify( + this.upData[this.upHead[i].label] + ); + } else { + this.upData[this.upHead[i].label] = ""; + } + } + } + this.upLoad = true; + this.$axios + .post(this.upUrl, this.upData, { + headers: { + "Content-Type": "application/json", + }, + }) + .then((res) => { + if (res.code === 201) { + this.upLoad = false; + return; + } + this.$message.success("淇敼鎴愬姛"); + this.upDia = false; + this.selectList("page"); + this.$refs.eltable.doLayout(); + this.upLoad = false; + }) + .catch((e) => { + this.$message.error("淇敼澶辫触"); + this.upDia = false; + this.upLoad = false; + }); + }, + // 鎵撳紑鏂板寮规鍥炶皟 + openAddDia(addUrl, param) { + this.addDia = true; + this.addUrl = addUrl; + this.param = param; + this.upData = {}; + this.tableHead.forEach((k, v) => { + if ( + k.label != "orderBy" && + k.label != "createTime" && + k.label != "updateTime" && + k.label != "createUser" && + k.label != "updateUser" + ) + this.upData[k.label] = null; + }); + this.upData = this.HaveJson(this.upData); + this.upHead = this.HaveJson(this.tableHead); + this.upHead = this.upHead.filter( + (a) => a.label != "createTime" && a.label != "updateTime" + ); + var val = this.data.do.filter((a) => a.id == "update")[0]; + if (val == undefined) { + val = { + field: [], + }; + } + val.field.forEach((a) => { + if (JSON.stringify(this.upData[a]) === undefined) { + this.upHead.push({ + value: a.split("=")[0], + label: a.split("=")[1], + }); + } else { + delete this.upData[a]; + for (var i = 0; i < this.upHead.length; i++) { + if (this.upHead[i].label == a) { + this.upHead.splice(i, 1); + i--; + break; + } + } + } + }); + }, + // 鏂板鍥炶皟 + saveAddData() { + if (this.addUrl == null) { + this.$message.error("璇风粰娣诲姞璇锋眰鍦板潃"); + return; + } + for (var i = 0; i < this.data.requiredAdd.length; i++) { + if ( + this.upData[this.data.requiredAdd[i]] === null || + this.upData[this.data.requiredAdd[i]] === "" + ) { + var list = this.upHead.filter((a) => { + if (a.label == this.data.requiredAdd[i]) return a; + }); + if (list[0].value == undefined) continue; + this.$message.error(list[0].value + "鏄繀濉」"); + return; + } + } + this.addLoad = true; + for (var a in this.data.selectField) { + if (this.data.selectField[a].choose == true) { + this.upData[a] = JSON.stringify(this.upData[a]); + } + } + this.upHead.forEach((item, index) => { + if (this.data.cascaderField && this.data.cascaderField[item.label]) { + if (this.upData[item.label]) { + this.upData[item.label] = JSON.stringify(this.upData[item.label]); + } else { + this.upData[item.label] = ""; + } + } + }); + if (this.param !== undefined && this.param !== null) { + for (let i in this.param) { + this.upData[i] = this.param[i]; + } + } + this.$axios + .post(this.addUrl, this.upData, { + headers: { + "Content-Type": "application/json", + }, + }) + .then((res) => { + if (res.code === 201) { + this.addLoad = false; + return; + } + this.$message.success("娣诲姞鎴愬姛"); + this.addDia = false; + this.selectList("page"); + this.addLoad = false; + }) + .catch((e) => { + this.addDia = false; + this.addLoad = false; + }); + }, + openDownDia() { + this.downDia = true; + }, + downFile(type) { + if (this.downUrl == null) { + this.$message.error("璇风粰瀵煎嚭璇锋眰鍦板潃"); + return; + } + var page = this.HaveJson(this.page); + if (!type) { + page.current = 0; + page.size = this.total; + } + this.loading = true; + this.$axios + .post( + this.downUrl, + { + page: page, + entity: this.data.entity, + }, + { + headers: { + "Content-Type": "application/json", + }, + } + ) + .then((res) => { + if (res.code === 201) { + this.loading = false; + return; + } + this.downDia = false; + this.loading = false; + this.$message.success("瀵煎嚭鎴愬姛"); + let eleLink = document.createElement("a"); + eleLink.style.display = "none"; + eleLink.download = res.data; + eleLink.href = this.javaApi + "/outPath/" + res.data; + document.body.appendChild(eleLink); + eleLink.click(); + document.body.removeChild(eleLink); + }) + .catch((e) => { + console.log(e); + this.loading = false; + this.$message.error("璇峰埛鏂伴〉闈㈠啀灏濊瘯"); + }); + }, + openUpload() { + if (this.inputUrl == null) { + this.$message.error("璇风粰瀵煎叆璇锋眰鍦板潃"); + return; + } + this.uploadDia = true; + }, + beforeUpload(file, fileList) { + console.log(file.raw.type); + if ( + file.raw.type != + (this.data.inputType === undefined ? "text/csv" : this.data.inputType) + ) { + this.$message.error("涓婁紶鏂囦欢鏍煎紡涓嶆纭�"); + this.$refs.upload.clearFiles(); + return false; + } + }, + submitUpload() { + if (this.$refs.upload.uploadFiles.length == 0) { + this.$message.error("鏈�夋嫨鏂囦欢"); + return; + } + this.uploading = true; + this.$refs.upload.submit(); + }, + onSuccess(response, file, fileList) { + this.$refs.upload.clearFiles(); + this.uploadDia = false; + this.uploading = false; + if (response.code == 201) { + this.$message.error(response.message); + return; + } + this.$message.success("涓婁紶鎴愬姛"); + this.selectList(); + }, + onError(err, file, fileList) { + this.$message.error("涓婁紶澶辫触"); + this.$refs.upload.clearFiles(); + this.uploading = false; + }, + // 鎿嶄綔鎸夐挳缃伆鍒ゆ柇 + isDisabled(label) { + if (this.data.disabledUp == undefined) { + return; + } + for (var i = 0; i < this.data.disabledUp.length; i++) { + if (label == this.data.disabledUp[i]) { + return true; + } + } + return false; + }, + getSummaries(param) { + const { columns, data } = param; + const sums = []; + columns.forEach((column, index) => { + if (index === 0) { + sums[index] = "鍚堣"; + return; + } + const values = data.map((item) => Number(item[column.property])); + if (this.data.countFleid == undefined) { + sums[index] = ""; + return; + } + if ( + this.data.countFleid.filter((str) => { + return str === column.property; + }).length > 0 + ) { + sums[index] = values.reduce((prev, curr) => { + const value = Number(curr); + if (!isNaN(value)) { + return prev + curr; + } else { + return prev; + } + }, 0); + sums[index] += ""; + } else { + sums[index] = ""; + } + }); + return sums; + }, + handleLinkEvent(row, val) { + if (val.method == "doDiy") { + this.main(row, val); + } else { + this.$parent[val.method](row); + } + }, + getWidth() { + let count = 0; + this.data.do.forEach((a) => { + count += a.font.length; + }); + return count * 15 + 60 + "px"; + }, + handleSuccessUp(response, label) { + if (typeof label === "string") { + if (response.code == 200) { + this.upData[label] = response.data.url; + } + } else { + if (response.code == 200) { + this.$message.success("涓婁紶鎴愬姛"); + this.selectList(); + } + } + }, + handleCascader(e, label) { + this.upData[label] = e; + }, + // 鎵归噺鍒犻櫎 + batchDelete() { + if (this.multipleSelection && this.multipleSelection.length > 0) { + this.$confirm("鏄惁鍒犻櫎閫変腑鐨勬暟鎹�?", "璀﹀憡", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning", + }) + .then(() => { + this.$axios + .post(this.delUrl, { + ids: JSON.stringify( + this.multipleSelection.map((item) => item.id) + ), + }) + .then((res) => { + if (res.code === 201) { + return; + } + this.$message.success("鍒犻櫎鎴愬姛"); + this.selectList("page"); + }) + .catch((e) => { + this.$message.error("鍒犻櫎澶辫触"); + }); + }) + .catch(() => {}); + } else { + this.$message.error("璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁"); + } + }, + // 鏃ュ伐鏃剁鐞嗚緟鍔╁伐鏃�--鎵归噺瀹℃牳鍜屾壒鍑� + batchCheck(e) { + if (this.multipleSelection && this.multipleSelection.length > 0) { + const list = JSON.parse(JSON.stringify(this.multipleSelection)); + const state = e === 0 ? "涓嶆壒鍑�" : "宸叉壒鍑�"; + let auxiliaryWorkingHoursDays = []; + list.forEach((item) => { + delete item.orderBy; + item.state = state; + auxiliaryWorkingHoursDays.push(item); + }); + this.$axios + .post( + this.$api.auxiliaryWorkingHoursDay.approve, + { auxiliaryWorkingHoursDays: auxiliaryWorkingHoursDays }, + { + headers: { + "Content-Type": "application/json", + }, + } + ) + .then((res) => { + if (res.code === 201) { + return; + } + this.$parent.submitBatchCheckDialog(); + this.$message.success("鎿嶄綔鎴愬姛"); + }); + } else { + this.$message.error("璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�"); + } + }, + getRedColor(label, row) { + if ( + this.data.cellSpecialStyle && + this.data.cellSpecialStyle.redColorByKey && + label.includes(this.data.cellSpecialStyle.redColorByKey) && + row[label.replace(this.data.cellSpecialStyle.redColorByKey, "")] + ) { + return true; + } else { + return false; + } + }, + }, +}; </script> -- Gitblit v1.9.3