| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- <template>
- <div>
- <el-dialog title="查看库区" :visible.sync="dialogVisible" append-to-body width="60%" :before-close="handleClose">
- <div style="display: flex;align-items: center;">
- <dic-select
- v-if="dialogVisible"
- style="width: 300px;"
- v-model="query.dot"
- placeholder="批次号"
- label="dot"
- :disabled="disabled || query.historyList.length"
- :url="'/blade-sales-part/stockDesc/dotList?storageId=' + form.storageId + '&goodsId=' + query.goodsId"
- :filterable="true"
- @selectChange="dicChange('dot', $event)"
- ></dic-select>
- <el-tag type="danger" style="margin-left: 10px;">出库数量:{{ qtyMax }}</el-tag>
- </div>
- <avue-crud
- v-if="dialogVisible"
- :option="option"
- :table-loading="loading"
- :data="data"
- ref="crud"
- id="out-table"
- :header-cell-class-name="headerClassName"
- >
- <template slot="quantity" slot-scope="{ row }">
- <el-input-number
- v-model="row.quantity"
- size="small"
- :controls="false"
- style="width: 100%"
- :max="row.balanceQuantity"
- :disabled="disabled"
- @change="qtyChange(row)"
- />
- </template>
- </avue-crud>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false" size="mini">取 消</el-button>
- <el-button type="primary" @click="submit" size="mini">确 认</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import { selectReservoirAreaList } from "@/api/tirePartsMall/salesManagement/outboundWorkOrder";
- import { head } from "lodash";
- import { isProcurement } from "@/api/basicData/configuration";
- import dicSelect from "@/components/dicSelect/main";
- export default {
- props: {
- disabled: {
- type: Boolean,
- default: false
- }
- },
- components: {
- dicSelect
- },
- data() {
- return {
- data: [],
- dialogVisible: false,
- loading: false,
- option: {
- height: 500,
- calcHeight: 30,
- border: true,
- index: true,
- addBtn: false,
- viewBtn: false,
- delBtn: false,
- editBtn: false,
- menu: false,
- header: false,
- column: [
- {
- label: "库区",
- prop: "reservoirAreaName",
- filters: true,
- sortable: true,
- overHidden: true
- },
- {
- label: "批次",
- prop: "dot",
- overHidden: true
- },
- {
- label: "库存",
- prop: "balanceQuantity",
- overHidden: true
- },
- {
- label: "本次数量",
- prop: "quantity",
- overHidden: true
- }
- ]
- },
- form: {},
- query: {},
- index: 0,
- qtyMax: 0
- };
- },
- async created() {},
- methods: {
- dicChange(name, row) {
- if (name == "dot") {
- if (row) {
- this.query.inventory = row.balanceQuantity;
- this.onLoad();
- } else {
- this.query.dot = null;
- this.onLoad();
- }
- }
- },
- qtyChange(row) {
- let sum = 0;
- for (let item of this.data) {
- sum += Number(item.quantity);
- }
- if (sum > this.qtyMax) {
- return this.$message.error("总数量不能超过" + this.qtyMax);
- }
- },
- onLoad() {
- let obj = {
- shipId: this.form.id,
- shipItemId: this.query.id,
- goodsId: this.query.goodsId,
- storageId: this.form.storageId,
- dot: this.query.dot
- };
- this.loading = true;
- selectReservoirAreaList(obj)
- .then(res => {
- this.data = res.data.data;
- })
- .finally(() => {
- this.loading = false;
- });
- },
- openDialog(form, row, index) {
- this.form = {};
- this.query = {};
- this.index = null;
- this.data = [];
- this.qtyMax = 0;
- this.form = form;
- this.query = row;
- this.index = index;
- this.data = this.deepClone(row.historyList);
- this.qtyMax = row.goodsNum;
- this.dialogVisible = true;
- if (row.historyList.length == 0) {
- this.onLoad();
- }
- },
- submit() {
- if (this.data.filter(item => item.quantity > 0).length == 0) {
- return this.$message.error("至少有一条本次数量不能为0");
- }
- for (let item of this.data.filter(item => item.quantity > 0)) {
- if (this.data.filter(item => item.quantity > 0)[0].dot != item.dot) {
- return this.$message.error("请选择一种批次号");
- }
- }
- if (!this.query.dot) {
- this.query.dot = this.data.filter(item => item.quantity > 0)[0].dot;
- }
- let sum = 0;
- for (let item of this.data) {
- sum += Number(item.quantity);
- }
- if (sum > this.qtyMax) {
- return this.$message.error("总数量不能超过" + this.qtyMax);
- }
- let obj = {
- ...this.query,
- sendNum: sum,
- historyList: this.data.filter(item => item.quantity > 0)
- };
- this.$emit("areaData", obj, this.index);
- this.dialogVisible = false;
- },
- //自定义列保存
- async saveColumn(ref, option, optionBack, code) {
- /**
- * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
- * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
- * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
- */
- const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
- if (inSave) {
- this.$message.success("保存成功");
- //关闭窗口
- this.$refs[ref].$refs.dialogColumn.columnBox = false;
- this.searchReset();
- }
- },
- //自定义列重置
- async resetColumn(ref, option, optionBack, code) {
- this[option] = this[optionBack];
- const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
- if (inSave) {
- this.$message.success("重置成功");
- this.$refs[ref].$refs.dialogColumn.columnBox = false;
- }
- },
- // 更改表格颜色
- headerClassName(tab) {
- //颜色间隔
- let back = "";
- if (tab.columnIndex >= 0 && tab.column.level === 1) {
- if (tab.columnIndex % 2 === 0) {
- back = "back-one";
- } else if (tab.columnIndex % 2 === 1) {
- back = "back-two";
- }
- }
- return back;
- }
- }
- };
- </script>
- <style scoped>
- ::v-deep#out-table .back-one {
- background: #ecf5ff !important;
- text-align: center;
- padding: 4px 0;
- }
- ::v-deep#out-table .back-two {
- background: #ecf5ff !important;
- text-align: center;
- padding: 4px 0;
- }
- </style>
|