viewArea.vue 7.5 KB

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