| | |
| | | :min="0" |
| | | :controls="false" |
| | | size="mini" |
| | | style="width: 81%" |
| | | style="width: 85%" |
| | | :disabled="!showFooter" |
| | | ></el-input-number> |
| | | </el-form-item> |
| | |
| | | :min="0" |
| | | :controls="false" |
| | | size="mini" |
| | | style="width: 81%" |
| | | style="width: 85%" |
| | | :disabled="!showFooter" |
| | | ></el-input-number> |
| | | </el-form-item> |
| | |
| | | import IconCropper from "./IconCropper" |
| | | import { getProductCategoryList } from "@/api/product/productCategory" |
| | | import { getProductList, addProduct, updateProduct } from "@/api/product/product" |
| | | import { uploadFiles } from "@/api/common/other" |
| | | |
| | | export default { |
| | | name: "AddProductDialog", |
| | |
| | | statisticsMap: { |
| | | inLibrary: 0 // 在库 |
| | | }, |
| | | isView: false |
| | | isView: false, |
| | | fileFormdata: null // 上传图片入参 |
| | | } |
| | | }, |
| | | created() { |
| | | if (this.editConfig.title === "编辑" && !this.editConfig.autoEdit) { |
| | | this.isView = true |
| | | } |
| | | // if (this.editConfig.title === "新建") { |
| | | // this.editConfig.infomation.imageSrc = "" |
| | | // } else { |
| | | // this.editConfig.infomation.imageSrc = "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg" |
| | | // } |
| | | this.getProductCategoryList() |
| | | this.getProductList() |
| | | this.setTableForm() |
| | |
| | | console.log(this.editConfig.infomation) |
| | | this.$refs[formName].validate((valid) => { |
| | | if (valid) { |
| | | let requestUrl = this.editConfig.title === "新建" ? addProduct : updateProduct |
| | | this.unsetFieldsToNumber() |
| | | requestUrl({ |
| | | ...this.editConfig.infomation |
| | | }).then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("添加成功") |
| | | this.$parent.getData() |
| | | console.log(this.fileFormdata == null) |
| | | let attachmentIDs = [] |
| | | if (this.fileFormdata == null) { |
| | | if (this.editConfig.infomation.attachmentList?.length > 0) { |
| | | this.editConfig.infomation.attachmentList.forEach((ele) => { |
| | | attachmentIDs.push(ele.id) |
| | | }) |
| | | } else { |
| | | attachmentIDs = [] |
| | | } |
| | | }, console.error) |
| | | this.saveEditRequest(attachmentIDs) |
| | | } else { |
| | | uploadFiles(this.fileFormdata).then((res) => { |
| | | if (res.code == 200) { |
| | | res.data.forEach((ele) => { |
| | | attachmentIDs.push(ele.id) |
| | | }) |
| | | } |
| | | this.saveEditRequest(attachmentIDs) |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | // 保存/编辑接口请求 |
| | | saveEditRequest(attachmentIDs) { |
| | | let requestUrl = this.editConfig.title === "新建" ? addProduct : updateProduct |
| | | this.unsetFieldsToNumber() |
| | | requestUrl({ |
| | | ...this.editConfig.infomation, |
| | | attachmentIDs |
| | | }).then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("添加成功") |
| | | this.$parent.getData() |
| | | } |
| | | }, console.error) |
| | | }, |
| | | // 删除 |
| | | delClick() {}, |
| | |
| | | this.tableData.splice(scope.$index, 1) |
| | | }, |
| | | // 上传图片 |
| | | getImageData(data) { |
| | | console.log(data, "图片数据") |
| | | getImageData(formdata) { |
| | | this.fileFormdata = formdata |
| | | // console.log(formdata, "图片数据") |
| | | }, |
| | | // 进出点击 |
| | | inOutBoundClick() { |