viewArea.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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;">出库数量:{{ 采购数量 }}</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="qtyMax"
  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. columnBtn: false,
  76. menu: false,
  77. header: false,
  78. column: [
  79. {
  80. label: "库区",
  81. prop: "reservoirAreaName",
  82. filters: true,
  83. sortable: true,
  84. overHidden: true
  85. },
  86. {
  87. label: "批次",
  88. prop: "dot",
  89. overHidden: true
  90. },
  91. {
  92. label: "库存",
  93. prop: "balanceQuantity",
  94. overHidden: true
  95. },
  96. {
  97. label: "本次数量",
  98. prop: "quantity",
  99. overHidden: true
  100. }
  101. ]
  102. },
  103. form: {},
  104. query: {},
  105. index: 0,
  106. qtyMax: 0
  107. };
  108. },
  109. async created() {},
  110. methods: {
  111. dicChange(name, row) {
  112. if (name == "dot") {
  113. if (row) {
  114. this.query.inventory = row.balanceQuantity;
  115. this.onLoad();
  116. } else {
  117. this.query.dot = null;
  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 = 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. let sum = 0;
  168. for (let item of this.data) {
  169. sum += Number(item.quantity);
  170. }
  171. if (sum > this.qtyMax) {
  172. return this.$message.error("总数量不能超过" + this.qtyMax);
  173. }
  174. let obj = {
  175. ...this.query,
  176. sendNum: sum,
  177. historyList: this.data.filter(item => item.quantity > 0)
  178. };
  179. this.$emit("areaData", obj, this.index);
  180. this.dialogVisible = false;
  181. },
  182. //自定义列保存
  183. async saveColumn(ref, option, optionBack, code) {
  184. /**
  185. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  186. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  187. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  188. */
  189. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  190. if (inSave) {
  191. this.$message.success("保存成功");
  192. //关闭窗口
  193. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  194. this.searchReset();
  195. }
  196. },
  197. //自定义列重置
  198. async resetColumn(ref, option, optionBack, code) {
  199. this[option] = this[optionBack];
  200. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  201. if (inSave) {
  202. this.$message.success("重置成功");
  203. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  204. }
  205. },
  206. // 更改表格颜色
  207. headerClassName(tab) {
  208. //颜色间隔
  209. let back = "";
  210. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  211. if (tab.columnIndex % 2 === 0) {
  212. back = "back-one";
  213. } else if (tab.columnIndex % 2 === 1) {
  214. back = "back-two";
  215. }
  216. }
  217. return back;
  218. }
  219. }
  220. };
  221. </script>
  222. <style scoped>
  223. ::v-deep#out-table .back-one {
  224. background: #ecf5ff !important;
  225. text-align: center;
  226. padding: 4px 0;
  227. }
  228. ::v-deep#out-table .back-two {
  229. background: #ecf5ff !important;
  230. text-align: center;
  231. padding: 4px 0;
  232. }
  233. </style>