viewArea.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <div>
  3. <el-dialog title="查看库区" :visible.sync="dialogVisible" append-to-body width="60%" :before-close="handleClose">
  4. <div style="display: flex;align-items: center;">
  5. <dic-select
  6. v-if="dialogVisible"
  7. style="width: 300px;"
  8. v-model="query.dot"
  9. placeholder="批次号"
  10. label="dot"
  11. :disabled="disabled || query.historyList.length"
  12. :url="'/blade-sales-part/stockDesc/dotList?storageId=' + form.storageId + '&goodsId=' + query.goodsId"
  13. :filterable="true"
  14. @selectChange="dicChange('dot', $event)"
  15. ></dic-select>
  16. <el-tag type="danger" style="margin-left: 10px;">出库数量:{{ qtyMax }}</el-tag>
  17. </div>
  18. <avue-crud
  19. v-if="dialogVisible"
  20. :option="option"
  21. :table-loading="loading"
  22. :data="data"
  23. ref="crud"
  24. id="out-table"
  25. :header-cell-class-name="headerClassName"
  26. >
  27. <template slot="quantity" slot-scope="{ row }">
  28. <el-input-number
  29. v-model="row.quantity"
  30. size="small"
  31. :controls="false"
  32. style="width: 100%"
  33. :max="row.balanceQuantity"
  34. :disabled="disabled"
  35. @change="qtyChange(row)"
  36. />
  37. </template>
  38. </avue-crud>
  39. <span slot="footer" class="dialog-footer">
  40. <el-button @click="dialogVisible = false" size="mini">取 消</el-button>
  41. <el-button type="primary" @click="submit" size="mini">确 认</el-button>
  42. </span>
  43. </el-dialog>
  44. </div>
  45. </template>
  46. <script>
  47. import { selectReservoirAreaList } from "@/api/tirePartsMall/salesManagement/outboundWorkOrder";
  48. import { head } from "lodash";
  49. import { isProcurement } from "@/api/basicData/configuration";
  50. import dicSelect from "@/components/dicSelect/main";
  51. export default {
  52. props: {
  53. disabled: {
  54. type: Boolean,
  55. default: false
  56. }
  57. },
  58. components: {
  59. dicSelect
  60. },
  61. data() {
  62. return {
  63. data: [],
  64. dialogVisible: false,
  65. loading: false,
  66. option: {
  67. height: 500,
  68. calcHeight: 30,
  69. border: true,
  70. index: true,
  71. addBtn: false,
  72. viewBtn: false,
  73. delBtn: false,
  74. editBtn: false,
  75. menu: false,
  76. header: false,
  77. column: [
  78. {
  79. label: "库区",
  80. prop: "reservoirAreaName",
  81. filters: true,
  82. sortable: true,
  83. overHidden: true
  84. },
  85. {
  86. label: "批次",
  87. prop: "dot",
  88. overHidden: true
  89. },
  90. {
  91. label: "库存",
  92. prop: "balanceQuantity",
  93. overHidden: true
  94. },
  95. {
  96. label: "本次数量",
  97. prop: "quantity",
  98. overHidden: true
  99. }
  100. ]
  101. },
  102. form: {},
  103. query: {},
  104. index: 0,
  105. qtyMax: 0
  106. };
  107. },
  108. async created() {},
  109. methods: {
  110. dicChange(name, row) {
  111. if (name == "dot") {
  112. if (row) {
  113. this.query.inventory = row.balanceQuantity;
  114. this.onLoad();
  115. } else {
  116. this.query.dot = null;
  117. }
  118. }
  119. },
  120. qtyChange(row) {
  121. let sum = 0;
  122. for (let item of this.data) {
  123. sum += Number(item.quantity);
  124. }
  125. if (sum > this.qtyMax) {
  126. return this.$message.error("总数量不能超过" + this.qtyMax);
  127. }
  128. },
  129. onLoad() {
  130. let obj = {
  131. shipId: this.form.id,
  132. shipItemId: this.query.id,
  133. goodsId: this.query.goodsId,
  134. storageId: this.form.storageId,
  135. dot: this.query.dot
  136. };
  137. this.loading = true;
  138. selectReservoirAreaList(obj)
  139. .then(res => {
  140. this.data = res.data.data;
  141. })
  142. .finally(() => {
  143. this.loading = false;
  144. });
  145. },
  146. openDialog(form, row, index) {
  147. this.form = {};
  148. this.query = {};
  149. this.index = null;
  150. this.data = [];
  151. this.qtyMax = 0;
  152. this.form = form;
  153. this.query = row;
  154. this.index = index;
  155. this.data = this.deepClone(row.historyList);
  156. this.qtyMax = row.remainingNum;
  157. this.dialogVisible = true;
  158. if (row.historyList.length == 0) {
  159. this.onLoad();
  160. }
  161. },
  162. submit() {
  163. if (this.data.filter(item => item.quantity > 0).length == 0) {
  164. return this.$message.error("至少有一条本次数量不能为0");
  165. }
  166. for (let item of this.data.filter(item => item.quantity > 0)) {
  167. if (this.data.filter(item => item.quantity > 0)[0].dot != item.dot) {
  168. return this.$message.error("请选择一种批次号");
  169. }
  170. }
  171. if (!this.query.dot) {
  172. this.query.dot = this.data.filter(item => item.quantity > 0)[0].dot;
  173. }
  174. let sum = 0;
  175. for (let item of this.data) {
  176. sum += Number(item.quantity);
  177. }
  178. if (sum > this.qtyMax) {
  179. return this.$message.error("总数量不能超过" + this.qtyMax);
  180. }
  181. if (Number(sum) != Number(this.qtyMax)) {
  182. this.$confirm("本次总数量和出库数量不相等,是否继续出库?", "提示", {
  183. confirmButtonText: "确定",
  184. cancelButtonText: "取消",
  185. type: "warning"
  186. }).then(() => {
  187. let obj = {
  188. ...this.query,
  189. sendNum: sum,
  190. historyList: this.data.filter(item => item.quantity > 0)
  191. };
  192. this.$emit("areaData", obj, this.index);
  193. this.dialogVisible = false;
  194. });
  195. } else {
  196. let obj = {
  197. ...this.query,
  198. sendNum: sum,
  199. historyList: this.data.filter(item => item.quantity > 0)
  200. };
  201. this.$emit("areaData", obj, this.index);
  202. this.dialogVisible = false;
  203. }
  204. },
  205. //自定义列保存
  206. async saveColumn(ref, option, optionBack, code) {
  207. /**
  208. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  209. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  210. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  211. */
  212. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  213. if (inSave) {
  214. this.$message.success("保存成功");
  215. //关闭窗口
  216. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  217. this.searchReset();
  218. }
  219. },
  220. //自定义列重置
  221. async resetColumn(ref, option, optionBack, code) {
  222. this[option] = this[optionBack];
  223. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  224. if (inSave) {
  225. this.$message.success("重置成功");
  226. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  227. }
  228. },
  229. // 更改表格颜色
  230. headerClassName(tab) {
  231. //颜色间隔
  232. let back = "";
  233. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  234. if (tab.columnIndex % 2 === 0) {
  235. back = "back-one";
  236. } else if (tab.columnIndex % 2 === 1) {
  237. back = "back-two";
  238. }
  239. }
  240. return back;
  241. }
  242. }
  243. };
  244. </script>
  245. <style scoped>
  246. ::v-deep#out-table .back-one {
  247. background: #ecf5ff !important;
  248. text-align: center;
  249. padding: 4px 0;
  250. }
  251. ::v-deep#out-table .back-two {
  252. background: #ecf5ff !important;
  253. text-align: center;
  254. padding: 4px 0;
  255. }
  256. </style>