Package.vue 11 KB

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