showInfo.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <div class="midPopUp" v-if="modelValue">
  3. <div class="body">
  4. <el-row :gutter="20">
  5. <el-col :span="14" class="leftView">
  6. <div class="btns">
  7. <!-- <el-button :class="selectedType == 'default' ? 'activeBtn' : ''" @click="setSelectedType('default')"
  8. type="primary" plain>全 部</el-button> -->
  9. <el-button :class="selectedType == 'yes' ? 'activeBtn' : ''" @click="setSelectedType('yes')"
  10. :disabled="disabled" type="primary" plain>符 合</el-button>
  11. <el-button :class="selectedType == 'no' ? 'activeBtn' : ''" @click="setSelectedType('no')"
  12. :disabled="disabled" type="primary" plain>不符合</el-button>
  13. <div class="submitBox">
  14. <el-button type="primary" @click="close" v-if="!bingdingStatus && !outboundStatus" plain>关 闭</el-button>
  15. <el-button type="primary" style="background-color: #f9bf5c90"
  16. v-if="!bingdingStatus && selectedType == 'yes'" @click="binding" plain>绑 定</el-button>
  17. <el-button @click="cancelBingding" type="primary" v-if="bingdingStatus || outboundStatus" plain>取
  18. 消</el-button>
  19. <el-button type="primary" style="background-color: #f9bf5c90" v-if="!bingdingStatus &&
  20. selectedType == 'no' &&
  21. outboundStatus == false
  22. " @click="outboundFnc" plain>出 库</el-button>
  23. <el-button type="primary" @click="submit" style="background-color: #f9bf5c90; color: white; border: 0px"
  24. v-if="bingdingStatus" plain>确 认</el-button>
  25. <el-button type="primary" @click="submit" style="background-color: #f9bf5c90; color: white; border: 0px"
  26. v-if="outboundStatus" plain>确 认</el-button>
  27. </div>
  28. </div>
  29. <div class="selectInfoBox">
  30. <el-scrollbar class="scrollbarTop">
  31. <div class="scroll">
  32. <div class="needMaterialInfo">
  33. <div>{{ selectRowData.materialName }}</div>
  34. <div>{{ selectRowData.materialCode }}</div>
  35. <div>
  36. 已装数量:{{
  37. selectRowData.completeNum
  38. ? selectRowData.completeNum
  39. : "-"
  40. }}
  41. </div>
  42. <div>所需总数:{{ selectRowData.totalMaterial }}</div>
  43. <div>
  44. 还需数量:{{
  45. selectRowData.totalMaterial -
  46. selectRowData.completeNum +
  47. topSum
  48. }}
  49. </div>
  50. </div>
  51. <div class="selectInfoItem" v-if="selectedType == 'yes'" @click="closeTopItem(item.selectedIndex)"
  52. v-for="item in setTopItem">
  53. <div>料箱名称:</div>
  54. <div>{{ item.name }}</div>
  55. <div>料箱编号:</div>
  56. <div>{{ item.code }}</div>
  57. </div>
  58. </div>
  59. </el-scrollbar>
  60. </div>
  61. <el-scrollbar class="scrollbar">
  62. <template v-for="(item, index) in materialData">
  63. <div :class="index == outboundIndex
  64. ? 'item bound'
  65. : item.selected == true
  66. ? 'item active'
  67. : item.isEnable == 2
  68. ? 'item noBound'
  69. : 'item'
  70. " v-if="itemShowStatus(item)" @click="setSelectIndex(index)">
  71. <div>料箱名称:</div>
  72. <div>{{ item.name }}</div>
  73. <div>料箱编号:</div>
  74. <div>{{ item.code }}</div>
  75. </div>
  76. </template>
  77. <Empty v-if="materialData.length < 1" />
  78. </el-scrollbar>
  79. </el-col>
  80. <el-col :span="10">
  81. <el-scrollbar class="infoBox">
  82. <el-table class="infoTable" :data="selectIndexInfoData" border>
  83. <el-table-column prop="materialName" label="物料名称" width="120" />
  84. <el-table-column prop="materialNo" label="物料编号" />
  85. <el-table-column prop="num" label="出入库数量" />
  86. <el-table-column prop="coordinate" label="储位坐标" />
  87. <template #empty>
  88. <Empty />
  89. </template>
  90. </el-table>
  91. </el-scrollbar>
  92. </el-col>
  93. </el-row>
  94. </div>
  95. <Bangding v-model="showStatus" :title="bindingTitle" @submit="submitData" :submitType="submitType"
  96. :outboundIndex="outboundIndex" />
  97. </div>
  98. </template>
  99. <script lang="ts" setup>
  100. import Bangding from "./bangding.vue";
  101. import { vehicleBiding, outBox } from "@/api/prepare";
  102. const props = defineProps({
  103. modelValue: {
  104. type: Boolean,
  105. default: false,
  106. },
  107. workOrderCode: {
  108. type: String,
  109. },
  110. operationId: {
  111. type: String,
  112. },
  113. });
  114. const emits = defineEmits(["update:modelValue", "resetOptionsData"]);
  115. const selectedType = ref("yes");
  116. const disabled = ref(false);
  117. const materialData = inject("materialData");
  118. const selectRowData = inject("selectRowData");
  119. const showStatus = ref(false);
  120. const outboundIndex = ref(null);
  121. const bindingTitle = ref("");
  122. //1-出库 2-绑定
  123. const submitType = ref(null);
  124. const bingdingStatus = ref(false);
  125. const outboundStatus = ref(false);
  126. const selectIndex = ref(0);
  127. const itemShowStatus = (item: any) => {
  128. if (selectedType.value == "yes") {
  129. if (item.isEnable == 1) {
  130. return true;
  131. } else {
  132. return false;
  133. }
  134. } else {
  135. if (item.isEnable == 0 || item.isEnable == 2) {
  136. return true;
  137. } else {
  138. return false;
  139. }
  140. }
  141. };
  142. const setSelectedType = (type: string) => {
  143. selectedType.value = type;
  144. };
  145. const outboundFnc = () => {
  146. outboundStatus.value = true;
  147. disabled.value = true;
  148. };
  149. const selectIndexInfoData = computed(() => {
  150. if (materialData.value.length > 0) {
  151. return materialData.value[selectIndex.value].list;
  152. } else {
  153. return [];
  154. }
  155. });
  156. //盒子点击事件
  157. const setSelectIndex = (index: number) => {
  158. selectIndex.value = index;
  159. if (selectedType.value == "yes") {
  160. //在符合的条件下
  161. if (bingdingStatus.value) {
  162. if (materialData.value[selectIndex.value].selected == true) {
  163. materialData.value[selectIndex.value].selected = false;
  164. } else {
  165. materialData.value[selectIndex.value].selected = true;
  166. }
  167. materialData.value[selectIndex.value].selectedIndex = index;
  168. }
  169. } else {
  170. //在不符合的条件下
  171. if (
  172. outboundStatus.value &&
  173. materialData.value[selectIndex.value].isEnable != 2
  174. ) {
  175. outboundIndex.value = selectIndex.value;
  176. }
  177. }
  178. };
  179. const closeTopItem = (index: number) => {
  180. materialData.value[index].selected = false;
  181. };
  182. //展示已选择的待绑定的盒子数组
  183. const setTopItem = computed(() => {
  184. return materialData.value.filter((item) => item.selected == true);
  185. });
  186. const topSum = computed(() => {
  187. let sum = 0;
  188. const array = materialData.value.filter((item) => item.selected == true);
  189. for (let i = 0; i++; i < array.length) {
  190. sum = array[i].xxxsum;
  191. }
  192. return sum;
  193. });
  194. const close = () => {
  195. emits("update:modelValue", false);
  196. reset();
  197. };
  198. const binding = () => {
  199. bingdingStatus.value = true;
  200. disabled.value = true;
  201. };
  202. const cancelBingding = () => {
  203. bingdingStatus.value = false;
  204. outboundStatus.value = false;
  205. disabled.value = false;
  206. };
  207. const submit = () => {
  208. if (outboundStatus.value == true) {
  209. bindingTitle.value = "确认出库";
  210. } else {
  211. bindingTitle.value = "绑定确认";
  212. }
  213. showStatus.value = true;
  214. };
  215. const reset = () => {
  216. selectedType.value = "yes";
  217. materialData.value = [];
  218. outboundIndex.value = null;
  219. };
  220. //提交函数(包含绑定、出库)
  221. const submitData = async () => {
  222. if (bingdingStatus.value == true) {
  223. const codes = [];
  224. materialData.value.forEach((item) => {
  225. if (item.selected == true) {
  226. codes.push(item.code);
  227. }
  228. });
  229. const { data, code } = await vehicleBiding({
  230. codes,
  231. operationId: props.operationId,
  232. workOrderCode: props.workOrderCode,
  233. });
  234. if (code == "200") {
  235. ElMessage.success("绑定成功!");
  236. emits("resetOptionsData");
  237. close();
  238. }
  239. } else {
  240. //出库
  241. const { data, code } = await outBox({
  242. vehicleNo: materialData.value[outboundIndex.value].code,
  243. taskId: 0,
  244. houseNo: materialData.value[outboundIndex.value].houseNo,
  245. });
  246. if (code == "200") {
  247. ElMessage.success("出库成功!");
  248. //页面数据删除
  249. materialData.value.splice(outboundIndex.value, 1);
  250. outboundIndex.value = null;
  251. }
  252. }
  253. };
  254. </script>
  255. <style lang="scss" scoped>
  256. :deep(.el-table__inner-wrapper:before) {
  257. width: 0 !important;
  258. }
  259. .bound {
  260. background-color: #a52a2a80 !important;
  261. color: white;
  262. }
  263. .noBound {
  264. background-color: grey !important;
  265. color: white;
  266. }
  267. .leftView {
  268. width: calc(100vw);
  269. .activeBtn {
  270. background-color: #6cc2ff !important;
  271. color: white !important;
  272. border: 0px !important;
  273. }
  274. }
  275. .body {
  276. display: flex;
  277. flex: 1;
  278. height: 100%;
  279. width: 100%;
  280. padding: 24px;
  281. .selectInfoBox {
  282. width: 100%;
  283. height: 160px;
  284. border-radius: 16px;
  285. background-color: #ffffff60;
  286. .scrollbarTop {
  287. padding: $p10;
  288. height: 170px;
  289. width: calc(100vw * 7 / 12 - 34px);
  290. margin-bottom: $p10;
  291. .scroll {
  292. display: flex;
  293. .needMaterialInfo {
  294. flex-shrink: 0;
  295. display: flex;
  296. flex-direction: column;
  297. justify-content: space-evenly;
  298. width: 200px;
  299. height: 140px;
  300. border-radius: 16px;
  301. background-color: #ffffff60;
  302. padding: $p10;
  303. div {
  304. font-size: $p20;
  305. line-height: 20px;
  306. width: 100%;
  307. }
  308. }
  309. .selectInfoItem {
  310. margin-left: $p10;
  311. flex-shrink: 0;
  312. width: 150px;
  313. height: 140px;
  314. border-radius: 16px;
  315. background-color: #ffffff60;
  316. background-image: url("@/assets/images/caijiwancheng.png");
  317. background-position: right top;
  318. background-repeat: no-repeat;
  319. padding: 20px;
  320. }
  321. }
  322. }
  323. }
  324. .infoBox {
  325. height: calc(100vh - 48px);
  326. width: calc(100vw * 5 / 12 - 48px);
  327. border-radius: 16px;
  328. background-color: #ffffff60;
  329. .infoTable {
  330. height: calc(100vh - 48px);
  331. background-color: white;
  332. }
  333. }
  334. .btns {
  335. width: 100%;
  336. height: 70px;
  337. display: flex;
  338. justify-content: space-evenly;
  339. padding-bottom: 10px;
  340. .submitBox {
  341. width: 300px;
  342. display: flex;
  343. justify-content: space-between;
  344. align-items: center;
  345. }
  346. .el-button {
  347. width: 150px;
  348. height: 60px;
  349. border: 1px solid #00000030;
  350. font-size: $f24;
  351. color: black;
  352. background-color: transparent;
  353. border-radius: 16px;
  354. }
  355. }
  356. .scrollbar {
  357. height: calc(100vh - 288px);
  358. margin-top: $p10;
  359. .item {
  360. width: 190px;
  361. height: 180px;
  362. border-radius: 16px;
  363. background-color: #ffffff60;
  364. display: inline-block;
  365. margin: $p20;
  366. padding: $p20;
  367. cursor: pointer;
  368. box-sizing: border-box;
  369. }
  370. }
  371. }
  372. .active {
  373. background-image: url("@/assets/images/caijiwancheng.png");
  374. background-position: right top;
  375. background-repeat: no-repeat;
  376. }
  377. </style>