Package.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <el-form
  3. class="form-no-message"
  4. ref="formRef"
  5. :show-message="false"
  6. label-position="left"
  7. :model="{
  8. ...workReport
  9. }"
  10. >
  11. <div class="message-box">
  12. <ul>
  13. <li> <span class="label">报工次数</span>{{ countMsg.reportNum }}</li>
  14. <li>
  15. <span class="label">累计合格品数量</span
  16. >{{ countMsg.standardTotalNum }}PCS</li
  17. >
  18. <li>
  19. <span class="label">累计合格品重量</span
  20. >{{ countMsg.standardTotalWeight }}KG</li
  21. >
  22. <li>
  23. <span class="label">累计投料产品数量</span
  24. >{{ countMsg.feedProductWeight }}PCS</li
  25. >
  26. </ul>
  27. <div class="right">
  28. <el-form-item
  29. label="执行人工号"
  30. prop="executorJobNum"
  31. required
  32. label-width="100px"
  33. ><personSelectRemote
  34. v-model="workReport.executorId"
  35. placeholder="请输入"
  36. @selfChange="
  37. (val, item) => (workReport.executorJobNum = item.jobNumber)
  38. "
  39. /></el-form-item>
  40. <el-form-item
  41. label="执行日期"
  42. required
  43. prop="executeTime"
  44. label-width="100px"
  45. ><el-date-picker
  46. v-model="workReport.executeTime"
  47. value-format="yyyy-MM-dd HH:mm:ss"
  48. type="datetime"
  49. format="yyyy-MM-dd HH:mm"
  50. placeholder="请选择"
  51. ></el-date-picker
  52. ></el-form-item>
  53. </div>
  54. </div>
  55. <el-card>
  56. <el-descriptions title="报工信息" direction="vertical" :column="5" border>
  57. <el-descriptions-item label="待交接数量">{{
  58. countMsg.surplusPackNum
  59. }}</el-descriptions-item>
  60. <el-descriptions-item label="实际数量(PCS)"
  61. ><el-input
  62. v-model="categoryMsg.number"
  63. placeholder="请输入"
  64. ></el-input
  65. ></el-descriptions-item>
  66. <el-descriptions-item label="选择包装要求">
  67. <el-select v-model="workReport.packInfo.packDemand">
  68. <el-option
  69. v-for="item in packageList"
  70. :key="item.code"
  71. :label="item.code"
  72. :value="item.code"
  73. @click.native="
  74. (item) => (packageRequirements = item.packageRequirements)
  75. "
  76. ></el-option>
  77. </el-select>
  78. </el-descriptions-item>
  79. <el-descriptions-item label="" :span="2">{{
  80. packageRequirements
  81. }}</el-descriptions-item>
  82. <el-descriptions-item label="包装数量"
  83. ><el-input
  84. v-model="workReport.packInfo.packNum"
  85. placeholder="请输入"
  86. ></el-input
  87. ></el-descriptions-item>
  88. <el-descriptions-item label="单位"
  89. ><el-input
  90. v-model="workReport.packInfo.packUnit"
  91. placeholder="请输入"
  92. ></el-input
  93. ></el-descriptions-item>
  94. <el-descriptions-item label="最小包装单元"
  95. ><el-input
  96. v-model="workReport.packInfo.minPackNum"
  97. placeholder="请输入"
  98. >
  99. <div class="suffix" slot="suffix"
  100. >PCS/{{ workReport.packInfo.packUnit }}</div
  101. >
  102. </el-input></el-descriptions-item
  103. >
  104. <el-descriptions-item label="尾数(PCS)"
  105. ><el-input
  106. v-model="workReport.packInfo.surplusNum"
  107. placeholder="请输入"
  108. ></el-input
  109. ></el-descriptions-item>
  110. <el-descriptions-item label="净重(KG)"
  111. ><el-input
  112. v-model="workReport.packInfo.netWeight"
  113. placeholder="请输入"
  114. ></el-input
  115. ></el-descriptions-item>
  116. <el-descriptions-item label="毛重(KG)"
  117. ><el-input
  118. v-model="workReport.packInfo.roughWeight"
  119. placeholder="请输入"
  120. ></el-input
  121. ></el-descriptions-item>
  122. </el-descriptions>
  123. <ele-pro-table
  124. :columns="columns"
  125. :datasource="workReportCategoryList"
  126. :need-page="false"
  127. class="mt-16"
  128. >
  129. <template v-slot:toolbar>
  130. <el-link type="primary" @click="addMaterial">添加物料</el-link>
  131. </template>
  132. <template v-slot:action="{ $index }">
  133. <el-link type="danger" @click="handleDelete($index)">删除</el-link>
  134. </template>
  135. <template v-slot:num="{ row }">
  136. <el-input v-model="row.number" placeholder="请输入"></el-input>
  137. </template>
  138. </ele-pro-table>
  139. <!-- <el-descriptions title="交接" direction="vertical" :column="5" border>
  140. <el-descriptions-item label="待交接数量"
  141. >kooriookami</el-descriptions-item
  142. >
  143. <el-descriptions-item label="实际数量(PCS)"
  144. >kooriookami</el-descriptions-item
  145. >
  146. </el-descriptions> -->
  147. </el-card>
  148. <ChooseMaterial ref="ChooseMaterialRef" @success="materialSuccess" />
  149. </el-form>
  150. </template>
  151. <script>
  152. import personSelectRemote from '@/components/CommomSelect/person-select-remote';
  153. import ChooseMaterial from '@/components/material/ChooseMaterial';
  154. import { reportCount, getPackageList } from '@/api/produceOrder';
  155. import dayjs from 'dayjs';
  156. export default {
  157. components: {
  158. ChooseMaterial,
  159. personSelectRemote
  160. },
  161. props: {
  162. infoData: {
  163. type: Object,
  164. default: () => ({})
  165. },
  166. taskInfo: {
  167. type: Object,
  168. default: () => ({})
  169. }
  170. },
  171. data () {
  172. return {
  173. packageRequirements: '',
  174. columns: [
  175. {
  176. label: '序号',
  177. type: 'index',
  178. width: 55
  179. },
  180. {
  181. label: '编码',
  182. prop: 'code'
  183. },
  184. {
  185. label: '名称',
  186. prop: 'name'
  187. },
  188. // {
  189. // label: '类型',
  190. // prop: 'index'
  191. // },
  192. {
  193. label: '型号',
  194. prop: 'model'
  195. },
  196. {
  197. label: '规格',
  198. prop: 'specification'
  199. },
  200. {
  201. label: '批次号',
  202. prop: 'batchNo'
  203. },
  204. // {
  205. // label: '包装编码',
  206. // prop: 'index'
  207. // },
  208. {
  209. label: '最小包装单元',
  210. prop: 'index',
  211. formatter: (row) =>
  212. `${row.netWeightUnit}${row.measuringUnit}/${row.packingUnit}`
  213. },
  214. {
  215. label: '数量',
  216. slot: 'num'
  217. },
  218. {
  219. label: '单位',
  220. prop: 'measuringUnit'
  221. },
  222. {
  223. label: '操作',
  224. slot: 'action'
  225. }
  226. ],
  227. categoryMsg: {
  228. batchNo: '',
  229. number: '',
  230. totalWeight: '',
  231. brandNum: '',
  232. sourceCategoryId: '',
  233. rootCategoryLevelId: '9',
  234. name: '',
  235. code: ''
  236. },
  237. workReport: {
  238. executorId: '',
  239. executorJobNum: '',
  240. executeTime: dayjs(new Date()).format('YYYY-MM-DD HH:mm'),
  241. packInfo: {
  242. packUnit: '',
  243. minPackNum: '',
  244. surplusNum: '',
  245. netWeight: '',
  246. roughWeight: '',
  247. packNum: '',
  248. netWeight: ''
  249. },
  250. productInfo: {
  251. standardNum: '',
  252. standardWeight: '',
  253. noStandardNum: '',
  254. noStandardWeight: ''
  255. }
  256. },
  257. packageList: [],
  258. workReportCategoryList: [],
  259. countMsg: {}
  260. };
  261. },
  262. watch: {
  263. taskInfo: {
  264. immediate: true,
  265. handler () {
  266. if (this.taskInfo.code) {
  267. this.getReportCount();
  268. }
  269. }
  270. },
  271. infoData: {
  272. immediate: true,
  273. handler () {
  274. if (this.infoData.code) {
  275. this._getPackageList();
  276. }
  277. }
  278. }
  279. },
  280. created () {
  281. this.workReport.executorId = this.$store.state.user.info?.userId;
  282. this.workReport.executorJobNum = this.$store.state.user.info?.jobNumber;
  283. },
  284. methods: {
  285. async _getPackageList () {
  286. const res = await getPackageList(this.infoData.code);
  287. this.packageList = res;
  288. },
  289. handleDelete (index) {
  290. this.$confirm('确定删除?', '提示').then(() => {
  291. this.workReportCategoryList.splice(index, 1);
  292. });
  293. },
  294. addMaterial () {
  295. this.$refs.ChooseMaterialRef.open(this.workReportCategoryList.slice(0));
  296. },
  297. materialSuccess (list) {
  298. const obj = {};
  299. this.workReportCategoryList = [
  300. ...this.workReportCategoryList,
  301. ...list
  302. ].reduce((next, pre) => {
  303. if (!obj[pre.id]) {
  304. obj[pre.id] = true;
  305. next.push({
  306. brandNo: pre.brandNum,
  307. code: pre.code,
  308. sourceCategoryId: pre.id,
  309. name: pre.name,
  310. model: pre.modelType,
  311. specifications: pre.specification,
  312. unit: pre.measuringUnit,
  313. number: '',
  314. ...pre
  315. });
  316. }
  317. return next;
  318. }, []);
  319. },
  320. async getReportCount () {
  321. const res = await reportCount({
  322. taskCode: this.taskInfo.code,
  323. lastTaskCode: this.taskInfo.lastTaskCode,
  324. workOrderId: this.infoData.id
  325. });
  326. this.countMsg = res;
  327. },
  328. getMsg () {},
  329. report (fun) {
  330. this.$refs.formRef.validate((value) => {
  331. if (value) {
  332. if (!this.workReportCategoryList?.length) {
  333. return this.$message.error('请添加物料');
  334. }
  335. this.$confirm('是否确定要报工?', '提示').then(() => {
  336. this.categoryMsg = Object.assign(this.categoryMsg, {
  337. brandNum: this.infoData.brandNo,
  338. sourceCategoryId: this.infoData.categoryId,
  339. name: this.infoData.productName,
  340. code: this.infoData.productCode
  341. });
  342. fun({
  343. checkState: 1,
  344. workReport: this.workReport,
  345. workReportCategoryList: [
  346. ...this.workReportCategoryList,
  347. this.categoryMsg
  348. ]
  349. }).then((res) => {
  350. this.$message.success('报工成功!');
  351. this.getReportCount();
  352. });
  353. });
  354. } else {
  355. this.$message.error('请输入必填项!');
  356. }
  357. });
  358. }
  359. }
  360. };
  361. </script>
  362. <style lang="scss" scoped>
  363. .suffix {
  364. height: 100%;
  365. display: flex;
  366. align-items: center;
  367. }
  368. .message-box {
  369. display: flex;
  370. justify-content: space-between;
  371. align-items: center;
  372. margin-bottom: 16px;
  373. .label {
  374. margin-right: 5px;
  375. }
  376. ul {
  377. list-style: none;
  378. display: flex;
  379. align-items: center;
  380. justify-content: flex-start;
  381. li {
  382. margin-right: 20px;
  383. }
  384. }
  385. .right {
  386. padding-top: 22px;
  387. display: flex;
  388. align-items: center;
  389. }
  390. }
  391. </style>