preparation.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. :title="`${title}-准备`"
  8. @clickLeft="back"
  9. >
  10. <view class="nav-right" slot="right">
  11. <view class="text-box" @click="addMaterial"> 添加物料 </view>
  12. </view>
  13. </uni-nav-bar>
  14. <uni-forms
  15. class="list"
  16. ref="form"
  17. :modelValue="formData"
  18. :rules="rules"
  19. validate-trigger="blur"
  20. >
  21. <div
  22. class="list-item"
  23. v-for="(item, index) in formData.list"
  24. :key="index"
  25. >
  26. <div class="item-title" @click="showContent(item)">
  27. <div>
  28. 物料编码 <span>{{ item.code }}</span>
  29. </div>
  30. <div class="title-delt" @click="remove(item, index)">删除</div>
  31. <!-- <image src="~@/static/product/xl.svg" :style="item.show?'transform: rotate(180deg)':''"></image> -->
  32. </div>
  33. <div class="item-content">
  34. <!-- v-if="item.show" -->
  35. <template>
  36. <div class="content-line">
  37. <div class="line-left">
  38. <span>物料名称</span>
  39. <p>{{ item.name }}</p>
  40. </div>
  41. </div>
  42. <!-- <div class="content-line">
  43. <div class="line-left">
  44. <span>类型</span>
  45. <p>{{ item.categoryLevelGroupName }}</p>
  46. </div>
  47. </div> -->
  48. <div class="content-line">
  49. <div class="line-left">
  50. <span>牌号</span>
  51. <p>{{ item.brandNum }}</p>
  52. </div>
  53. </div>
  54. <div class="content-line">
  55. <div class="line-left">
  56. <span>型号</span>
  57. <p>{{ item.model }}</p>
  58. </div>
  59. </div>
  60. <div class="content-line">
  61. <div class="line-left">
  62. <span>需求数量</span>
  63. <p>
  64. <!-- :rules="[{'required': true,errorMessage: '生产数量必填'},{pattern:/^[1-9]\d*$/,errorMessage: '请输入正整数',trigger: 'blur'}]" -->
  65. <uni-forms-item
  66. ref="input"
  67. :key="item.id"
  68. :name="['list', index, 'demandWeight']"
  69. style="margin-top: 30rpx"
  70. >
  71. <uni-easyinput
  72. size="small"
  73. type="number"
  74. v-model="item.demandWeight"
  75. />
  76. </uni-forms-item>
  77. PCS
  78. </p>
  79. </div>
  80. <div class="line-right">
  81. <u-button
  82. class="right-minus"
  83. @click="reduce(item, index)"
  84. :disabled="item.demandWeight < 2"
  85. >-</u-button
  86. >
  87. <u-button class="right-add" @click="add(item, index)"
  88. >+</u-button
  89. >
  90. </div>
  91. </div>
  92. <div class="content-line">
  93. <div class="line-left">
  94. <span>仓库</span>
  95. <uni-forms-item
  96. ref="input"
  97. :rules="[{ required: true, errorMessage: '仓库是必选' }]"
  98. :key="item.id"
  99. :name="['list', index, 'warehouse']"
  100. style="margin-top: 40rpx"
  101. >
  102. <uni-easyinput
  103. :value="item.warehouse"
  104. readonly
  105. placeholder="请输入"
  106. size="small"
  107. @click.native="choose(item, index)"
  108. />
  109. </uni-forms-item>
  110. </div>
  111. </div>
  112. <!-- <div class="content-delt" @click="remove(item,index)">删除</div> -->
  113. </template>
  114. <!-- <div class="content-line" v-else>
  115. <span>{{ item.name }}</span>
  116. <div class="line-right">
  117. 400{{item.measuringUnit}}
  118. </div>
  119. </div> -->
  120. </div>
  121. </div>
  122. </uni-forms>
  123. <div class="footer">
  124. <div class="footer-btn" @click="submit">领料</div>
  125. </div>
  126. <locationPopu
  127. ref="locationRef"
  128. @checkLocation="comfirmLocation"
  129. ></locationPopu>
  130. <materialDialog
  131. ref="materialDialogRef"
  132. @affirm="comfirmChoose"
  133. :chooseList="formData.list"
  134. :params="materialPar"
  135. />
  136. </view>
  137. </template>
  138. <script>
  139. import { post, postJ, get, getJ } from "@/utils/api.js";
  140. import materialDialog from "./components/materialDialog.vue";
  141. import locationPopu from "../components/locationPopu.vue";
  142. import { batchSave, getLoginUser } from "@/api/production/extrusion.js";
  143. export default {
  144. components: {
  145. materialDialog,
  146. locationPopu,
  147. },
  148. data() {
  149. return {
  150. title: "挤压成型",
  151. formData: {
  152. list: [],
  153. },
  154. rules: {},
  155. chooseIndex: null,
  156. code: "",
  157. id: "",
  158. userInfo: {},
  159. //正整数正则 /^[1-9]\d*$/
  160. materialPar: {},
  161. };
  162. },
  163. onLoad({ id, code, taskInstanceId, versionId }) {
  164. if (id) {
  165. this.id = id;
  166. }
  167. if (code) {
  168. this.code = code;
  169. }
  170. this.materialPar = {
  171. taskInstanceId,
  172. versionId,
  173. };
  174. this.getUserInfo();
  175. },
  176. methods: {
  177. showContent(item) {
  178. this.$set(item, "show", !item.show);
  179. },
  180. remove(item, index) {
  181. this.formData.list.splice(index, 1);
  182. },
  183. reduce(item, index) {
  184. this.$set(
  185. this.formData.list[index],
  186. "demandWeight",
  187. Number(item.demandWeight) - 1
  188. );
  189. },
  190. add(item, index) {
  191. this.$set(
  192. this.formData.list[index],
  193. "demandWeight",
  194. Number(item.demandWeight) + 1
  195. );
  196. },
  197. choose(item, index) {
  198. this.chooseIndex = index;
  199. this.$refs.locationRef.open();
  200. },
  201. submit() {
  202. this.$refs.form
  203. .validate()
  204. .then((res) => {
  205. batchSave({
  206. ...this.userInfo,
  207. pickOrderList: this.formData.list,
  208. }).then((res) => {
  209. if (res) {
  210. uni.$u.toast("提交成功!");
  211. uni.navigateBack({
  212. delta: 1,
  213. });
  214. }
  215. });
  216. })
  217. .catch((err) => {
  218. uni.$u.toast("请补全信息!");
  219. });
  220. },
  221. addMaterial() {
  222. this.$refs.materialDialogRef.open();
  223. },
  224. comfirmChoose(list) {
  225. // 取出在弹窗中选中并且不在表格中的数据
  226. list = list.map((item) => ({
  227. ...item,
  228. name: item.categoryName,
  229. code: item.categoryCode,
  230. sourceCategoryId: item.id,
  231. brandNum: item.brandNum,
  232. factoryCode: item.factoryCode,
  233. }));
  234. const result = list.filter(
  235. (i) => this.formData.list.findIndex((p) => p.id === i.id) === -1
  236. );
  237. // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
  238. const del = this.formData.list.filter(
  239. (i) => list.findIndex((p) => p.id === i.id) === -1
  240. );
  241. for (let i = this.formData.list.length - 1; i >= 0; i--) {
  242. for (let j in del) {
  243. if (this.formData.list[i].id === del[j].id) {
  244. this.formData.list.splice(i, 1);
  245. }
  246. }
  247. }
  248. this.formData.list = this.formData.list.concat(
  249. result.map((item, index) => {
  250. this.$set(item, "demandWeight", 0);
  251. this.$set(item, "warehouse", "");
  252. this.$set(item, "warehouseId", "");
  253. this.$set(item, "workOrderCode", this.code);
  254. this.$set(item, "workOrderId", this.id);
  255. return item;
  256. })
  257. );
  258. },
  259. comfirmLocation(cho) {
  260. if (cho.warehouseId) {
  261. this.$set(
  262. this.formData.list[this.chooseIndex],
  263. "warehouseId",
  264. cho.warehouseId
  265. );
  266. this.$set(
  267. this.formData.list[this.chooseIndex],
  268. "warehouse",
  269. cho.warehouse
  270. );
  271. }
  272. },
  273. getUserInfo() {
  274. getLoginUser().then((res) => {
  275. this.userInfo.executorId = res.accountId;
  276. this.userInfo.executorName = res.name;
  277. });
  278. },
  279. },
  280. };
  281. </script>
  282. <style lang="scss" scoped>
  283. .list {
  284. width: 94%;
  285. margin: 0 auto;
  286. padding: 0 0 100rpx;
  287. .list-item {
  288. width: 100%;
  289. margin: 20rpx auto 40rpx;
  290. .item-title {
  291. padding: 0 12rpx;
  292. border-bottom: 1rpx solid #ccc;
  293. display: flex;
  294. align-items: center;
  295. justify-content: space-between;
  296. font-size: 30rpx;
  297. color: #000;
  298. font-weight: bold;
  299. height: 80rpx;
  300. line-height: 80rpx;
  301. image {
  302. width: 21rpx;
  303. height: 11rpx;
  304. }
  305. span {
  306. margin-left: 15rpx;
  307. }
  308. .title-delt {
  309. color: #ec808d;
  310. // margin: 30rpx auto 0;
  311. width: 100rpx;
  312. text-align: center;
  313. }
  314. }
  315. .item-content {
  316. .content-line {
  317. padding: 0 12rpx;
  318. border-bottom: 1rpx dashed #ccc;
  319. display: flex;
  320. align-items: center;
  321. justify-content: space-between;
  322. height: 80rpx;
  323. line-height: 80rpx;
  324. .line-left {
  325. display: flex;
  326. align-items: center;
  327. justify-content: flex-start;
  328. span {
  329. width: 180rpx;
  330. text-align: left;
  331. color: rgb(127, 127, 127);
  332. }
  333. p {
  334. color: #333333;
  335. display: flex;
  336. align-items: center;
  337. justify-content: flex-start;
  338. /deep/.uni-easyinput {
  339. width: 220rpx;
  340. margin-right: 10rpx;
  341. height: 20rpx !important;
  342. .uni-easyinput__content {
  343. height: 70rpx !important;
  344. }
  345. }
  346. }
  347. }
  348. .line-right {
  349. display: flex;
  350. align-items: center;
  351. justify-content: flex-end;
  352. .right-minus {
  353. width: 80rpx;
  354. height: 51rpx;
  355. text-align: center;
  356. line-height: 51rpx;
  357. color: #fff;
  358. background: #f59a23;
  359. border: none;
  360. }
  361. .right-add {
  362. width: 80rpx;
  363. height: 51rpx;
  364. text-align: center;
  365. line-height: 51rpx;
  366. color: #fff;
  367. background: #70b603;
  368. margin-left: 10rpx;
  369. border: none;
  370. }
  371. .right-add.right-choose {
  372. width: 120rpx;
  373. }
  374. }
  375. }
  376. }
  377. }
  378. }
  379. .footer {
  380. width: 100%;
  381. height: 90rpx;
  382. position: fixed;
  383. bottom: 0;
  384. left: 0;
  385. .footer-btn {
  386. width: 100%;
  387. height: 90rpx;
  388. line-height: 90rpx;
  389. display: flex;
  390. align-items: center;
  391. justify-content: center;
  392. font-size: 34rpx;
  393. color: #fff;
  394. background: #70b603;
  395. }
  396. }
  397. </style>