| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <template>
- <div>
- <el-button
- type="primary"
- :size="btn_size ? btn_size : 'small'"
- @click="onshow"
- :disabled="disabled"
- :loading="loading"
- >{{ btnName ? $t(btnName) : $t(`批量添加至本站`) }}</el-button
- >
- </div>
- </template>
- <script>
- export default {
- props: ["rowData", "disabled", "btnName", "btn_size"],
- name: "counterExamine",
- data() {
- return {
- loading: false,
- };
- },
- methods: {
- onshow() {
- 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 () => {
- this.loading = true;
- let row = [];
- dataList.forEach(function (item, index) {
- row[index] = item.sc_itemid;
- });
- const sc_itemids_str = row.join(",");
- const res = await this.$api.requested({
- id: 2026051511000001,
- content: {
- sc_itemids: sc_itemids_str,
- },
- });
- this.loading = false;
- this.tool.showMessage(res, () => {
- this.$emit("addSuccess");
- });
- })
- .catch(async () => {
- this.$message({
- type: "info",
- message: cancelText,
- });
- });
- },
- },
- };
- </script>
- <style scoped>
- </style>
|