viewArea.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. this.onLoad();
  118. }
  119. }
  120. },
  121. qtyChange(row) {
  122. let sum = 0;
  123. for (let item of this.data) {
  124. sum += Number(item.quantity);
  125. }
  126. if (sum > this.qtyMax) {
  127. return this.$message.error("总数量不能超过" + this.qtyMax);
  128. }
  129. },
  130. onLoad() {
  131. let obj = {
  132. shipId: this.form.id,
  133. shipItemId: this.query.id,
  134. goodsId: this.query.goodsId,
  135. storageId: this.form.storageId,
  136. dot: this.query.dot
  137. };
  138. this.loading = true;
  139. selectReservoirAreaList(obj)
  140. .then(res => {
  141. this.data = res.data.data;
  142. })
  143. .finally(() => {
  144. this.loading = false;
  145. });
  146. },
  147. openDialog(form, row, index) {
  148. this.form = {};
  149. this.query = {};
  150. this.index = null;
  151. this.data = [];
  152. this.qtyMax = 0;
  153. this.form = form;
  154. this.query = row;
  155. this.index = index;
  156. this.data = this.deepClone(row.historyList);
  157. this.qtyMax = row.goodsNum;
  158. this.dialogVisible = true;
  159. if (row.historyList.length == 0) {
  160. this.onLoad();
  161. }
  162. },
  163. submit() {
  164. if (this.data.filter(item => item.quantity > 0).length == 0) {
  165. return this.$message.error("至少有一条本次数量不能为0");
  166. }
  167. for (let item of this.data.filter(item => item.quantity > 0)) {
  168. if (this.data.filter(item => item.quantity > 0)[0].dot != item.dot) {
  169. return this.$message.error("请选择一种批次号");
  170. }
  171. }
  172. if (!this.query.dot) {
  173. this.query.dot = this.data.filter(item => item.quantity > 0)[0].dot;
  174. }
  175. let sum = 0;
  176. for (let item of this.data) {
  177. sum += Number(item.quantity);
  178. }
  179. if (sum > this.qtyMax) {
  180. return this.$message.error("总数量不能超过" + this.qtyMax);
  181. }
  182. let obj = {
  183. ...this.query,
  184. sendNum: sum,
  185. historyList: this.data.filter(item => item.quantity > 0)
  186. };
  187. this.$emit("areaData", obj, this.index);
  188. this.dialogVisible = false;
  189. },
  190. //自定义列保存
  191. async saveColumn(ref, option, optionBack, code) {
  192. /**
  193. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  194. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  195. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  196. */
  197. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  198. if (inSave) {
  199. this.$message.success("保存成功");
  200. //关闭窗口
  201. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  202. this.searchReset();
  203. }
  204. },
  205. //自定义列重置
  206. async resetColumn(ref, option, optionBack, code) {
  207. this[option] = this[optionBack];
  208. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  209. if (inSave) {
  210. this.$message.success("重置成功");
  211. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  212. }
  213. },
  214. // 更改表格颜色
  215. headerClassName(tab) {
  216. //颜色间隔
  217. let back = "";
  218. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  219. if (tab.columnIndex % 2 === 0) {
  220. back = "back-one";
  221. } else if (tab.columnIndex % 2 === 1) {
  222. back = "back-two";
  223. }
  224. }
  225. return back;
  226. }
  227. }
  228. };
  229. </script>
  230. <style scoped>
  231. ::v-deep#out-table .back-one {
  232. background: #ecf5ff !important;
  233. text-align: center;
  234. padding: 4px 0;
  235. }
  236. ::v-deep#out-table .back-two {
  237. background: #ecf5ff !important;
  238. text-align: center;
  239. padding: 4px 0;
  240. }
  241. </style>