|
|
@@ -17,9 +17,16 @@
|
|
|
<el-button @click="queryData()">查询</el-button>
|
|
|
<el-button @click="noticeSettingHandle(null, false)">通知设置</el-button>
|
|
|
<el-button type="primary" @click="templateDownload">清单模板下载</el-button>
|
|
|
+ <el-button type="primary" @click="batchImport">批量导入</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
- <el-table :data="dataList" border v-loading="dataListLoading" style="width: 100%;">
|
|
|
+ <el-table :data="dataList" border v-loading="dataListLoading" ref="multipleTable" style="width: 100%;"
|
|
|
+ @selection-change="handleSelectionChange" @select="handleSelect">
|
|
|
+ <el-table-column
|
|
|
+ type="selection"
|
|
|
+ :selectable="checkSelectable"
|
|
|
+ width="55"
|
|
|
+ />
|
|
|
<el-table-column label="序号" type="index" width="100" align="center">
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="projectName" header-align="center" align="center" min-width="140"
|
|
|
@@ -70,6 +77,13 @@
|
|
|
<el-button size="small" type="success" @click="submitUpload">开始上传</el-button>
|
|
|
</el-upload>
|
|
|
</el-dialog>
|
|
|
+ <el-dialog title="批量导入" :visible.sync="importBatchVisible">
|
|
|
+ <el-upload class="upload-demo" ref="uploadBatch" :on-remove="handleRemoveBatch" action="#" accept="" :limit="1"
|
|
|
+ :file-list="fileList" :auto-upload="false" :http-request="handleUploadBatch" v-loading="importBatchLoading">
|
|
|
+ <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
|
|
|
+ <el-button size="small" type="success" @click="submitUploadBatch">开始上传</el-button>
|
|
|
+ </el-upload>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -106,7 +120,11 @@ export default {
|
|
|
stateOption: [
|
|
|
{ label: '待处理', value: '1' },
|
|
|
{ label: '已处理', value: '2' }
|
|
|
- ]
|
|
|
+ ],
|
|
|
+ selectedOrderCode: '@@',
|
|
|
+ currentSelection: [],
|
|
|
+ importBatchVisible: false,
|
|
|
+ importBatchLoading: false
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
@@ -123,6 +141,86 @@ export default {
|
|
|
templateDownload() {
|
|
|
location.href = this.$http.adornUrl(`/biz-service/product/template/download?_token=${Vue.cookie.get('token')}`)
|
|
|
},
|
|
|
+ //批量导入
|
|
|
+ batchImport(){
|
|
|
+ if(this.currentSelection.length == 0){
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: '请勾选数据'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.importBatchVisible = true;
|
|
|
+ },
|
|
|
+ // 移除
|
|
|
+ handleRemoveBatch(file, fileList) {
|
|
|
+ this.$emit('input', fileList)
|
|
|
+ },
|
|
|
+ handleUploadBatch(file) {
|
|
|
+ if (file == null) {
|
|
|
+ this.$message.error('请上传文件')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.importBatchLoading = true
|
|
|
+
|
|
|
+ const formData = new FormData();
|
|
|
+ formData.append("importFile", file.file);
|
|
|
+ formData.append("productTechnologyDataList[0].productTechnologyId", this.currentSelection[0].productTechnologyId);
|
|
|
+ formData.append("productTechnologyDataList[0].productName", this.currentSelection[0].productName);
|
|
|
+ this.$http({
|
|
|
+ url: this.$http.adornUrl(`/biz-service/projProduct/batch/importExcel`),
|
|
|
+ method: "POST",
|
|
|
+ data: formData,
|
|
|
+ timeout: 0,
|
|
|
+ }).then(({ data }) => {
|
|
|
+ this.importBatchLoading = false;
|
|
|
+ if (data && data.code === "200") {
|
|
|
+ this.$message({
|
|
|
+ message: "导入成功",
|
|
|
+ type: "success",
|
|
|
+ duration: 1500,
|
|
|
+ onClose: () => {
|
|
|
+ this.importBatchVisible = false;
|
|
|
+ this.getDataList()
|
|
|
+ },
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$message.error(data.msg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 上传
|
|
|
+ submitUploadBatch() {
|
|
|
+ this.$refs.uploadBatch.submit()
|
|
|
+ },
|
|
|
+ handleSelectionChange(val) {
|
|
|
+ console.log(val)
|
|
|
+ this.currentSelection = val
|
|
|
+ },
|
|
|
+ // 处理单选/多选操作(核心逻辑)
|
|
|
+ handleSelect(selection, row){
|
|
|
+ // selection: 当前所有选中行数组;row: 当前被操作的行
|
|
|
+ const isSelected = selection.includes(row); // 当前行是被选中还是取消选中
|
|
|
+ if (isSelected) {
|
|
|
+ // 情况1:当前行被选中
|
|
|
+ this.selectedOrderCode = row.orderCode; // 更新选中 type
|
|
|
+ } else {
|
|
|
+ // 情况2:当前行被取消选中
|
|
|
+ if (selection.length === 0) {
|
|
|
+ // 如果没有选中行了,重置 selectedType,恢复所有行可选
|
|
|
+ this.selectedOrderCode = '@@';
|
|
|
+ } else {
|
|
|
+ // 如果还有选中行,确保所有选中行 type 一致(以第一个选中行为准)
|
|
|
+ this.selectedOrderCode = selection[0].orderCode;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ checkSelectable(row) {
|
|
|
+ // 根据需要处理勾选状态,例如更新 selected 数组等。
|
|
|
+ return this.selectedOrderCode === '@@' || row.orderCode === this.selectedOrderCode;
|
|
|
+ },
|
|
|
// 查询
|
|
|
queryData() {
|
|
|
this.pageIndex = 1
|