|
|
@@ -0,0 +1,96 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ :size="btn_size ? btn_size : 'small'"
|
|
|
+ @click="onshow"
|
|
|
+ :disabled="disabled"
|
|
|
+ >{{ btnName ? $t(btnName) : $t(`批量添加至本站`) }}</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ props: ["rowData", "disabled", "btnName", "btn_size"],
|
|
|
+ name: "counterExamine",
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ flag: false,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onshow() {
|
|
|
+ // 统一处理 单个对象 / 数组
|
|
|
+ const dataList = this.btnName ? [this.rowData] : this.rowData;
|
|
|
+ this.flag = false;
|
|
|
+ // 统一用 dataList 遍历
|
|
|
+ dataList.forEach((e) => {
|
|
|
+ if (e.shelf === 0) {
|
|
|
+ this.flag = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (this.flag) {
|
|
|
+ this.$alert(
|
|
|
+ this.$t("所选数据中有数据还未上架,请检查后再进行操作"),
|
|
|
+ this.$t("提示"),
|
|
|
+ {
|
|
|
+ confirmButtonText: this.$t("确定"),
|
|
|
+ callback: (action) => {
|
|
|
+ this.$message({
|
|
|
+ type: "info",
|
|
|
+ message: this.$t(`请检查所选数据`),
|
|
|
+ });
|
|
|
+ },
|
|
|
+ }
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ this.onCounter();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onCounter() {
|
|
|
+ //根据是否传入 btnName 切换 单数/批量 文案
|
|
|
+ const isSingle = !!this.btnName;
|
|
|
+ const confirmText = isSingle
|
|
|
+ ? this.$t("是否确定将此物料添加至本站")
|
|
|
+ : this.$t("是否确定将所选物料添加至本站");
|
|
|
+ const cancelText = isSingle
|
|
|
+ ? this.$t("已取消添加至本站")
|
|
|
+ : this.$t("已取消批量添加至本站");
|
|
|
+ // 统一兼容数据格式
|
|
|
+ const dataList = this.btnName ? [this.rowData] : this.rowData;
|
|
|
+ this.$confirm(confirmText + "?", this.$t("提示"), {
|
|
|
+ confirmButtonText: this.$t("确定"),
|
|
|
+ cancelButtonText: this.$t("取消"),
|
|
|
+ type: "warning",
|
|
|
+ })
|
|
|
+ .then(async () => {
|
|
|
+ let row = [];
|
|
|
+ dataList.forEach(function (item, index) {
|
|
|
+ row[index] = item.sc_itemid;
|
|
|
+ });
|
|
|
+ // 把数组转成 逗号分隔的字符串 "1,2,3"
|
|
|
+ const sc_itemids_str = row.join(",");
|
|
|
+ const res = await this.$api.requested({
|
|
|
+ id: 2026051511000001,
|
|
|
+ content: {
|
|
|
+ sc_itemids: sc_itemids_str,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ this.tool.showMessage(res, () => {
|
|
|
+ this.$emit("addSuccess");
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(async () => {
|
|
|
+ this.$message({
|
|
|
+ type: "info",
|
|
|
+ message: cancelText,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+</style>
|