index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <div class="page-container column-container">
  3. <section class="list-part-container column-container" style="flex: 1">
  4. <!-- 搜索区 -->
  5. <el-form class="list-search-container" :model="queryParams" ref="queryRef" :inline="true">
  6. <el-form-item class="section-title" label="生产计划" />
  7. <el-form-item label="生产计划单号:">
  8. <el-input placeholder="请输入生产计划单号" v-model.trim="queryParams.productionPlanNo"
  9. @keyup.enter="handleQueryProductionPlanDetail" @keydown.enter.prevent clearable style="width: 200px" />
  10. </el-form-item>
  11. <el-form-item label="产品描述:">
  12. <el-input placeholder="请输入产品描述" v-model.trim="queryParams.keywords"
  13. @keyup.enter="handleQueryProductionPlanDetail" @keydown.enter.prevent clearable style="width: 200px" />
  14. </el-form-item>
  15. <el-form-item>
  16. <el-button type="info" icon="Search" @click="handleQueryProductionPlanDetail">
  17. 搜索
  18. </el-button>
  19. </el-form-item>
  20. <el-form-item class="section-title" label="请选择当前工段:">
  21. <el-select-v2 v-model="queryParams.deptId" filterable :options="deptList" placeholder="请选择工段"
  22. style="width: 100%" @change="handleDeptChange" />
  23. </el-form-item>
  24. </el-form>
  25. <div class="el-table-container">
  26. <div class="el-table-inner-container">
  27. <el-table ref="planDetailTable" :data="detailPlanList" v-loading="detailLoading" highlight-current-row
  28. height="100%" @current-change="handlePlanDetailCurrentChange">
  29. <el-table-column label="客户简称" prop="companyAlias" width="120" align="center" />
  30. <el-table-column label="生产计划单号" prop="productionPlanNo" width="110" align="center" />
  31. <el-table-column label="序号" width="60" prop="lineNumber" align="center" />
  32. <el-table-column label="产品描述" prop="productDescription" align="center" />
  33. <el-table-column label="图纸版本" prop="technologyVersion" width="70" align="center" />
  34. <el-table-column label="总投产量" prop="productionQuantity" width="80" align="center" />
  35. <el-table-column label="总批数" prop="totalLotNumber" width="70" align="center" />
  36. <el-table-column label="单批量" prop="oneLotQuantity" width="80" align="center" />
  37. <el-table-column label="尾批量" prop="lastLotQuantity" width="80" align="center" />
  38. <el-table-column label="批号状态" prop="lotCodeStatusCode" width="100" align="center">
  39. <template #default="scope">
  40. <dict-tag :options="lot_code_status_code" :value="scope.row.lotCodeStatusCode" />
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="累计投产量" prop="pickUpQuantity" width="80" align="center" />
  44. <el-table-column label="累计投产批数" prop="lotTotalNumber" width="90" align="center" />
  45. <el-table-column label="库位" prop="storageLocation" width="80" align="center" />
  46. <el-table-column label="领料部门" prop="requisitionDepartmentName" width="100" align="center">
  47. <template #default="scope">
  48. <span>{{ scope.row.requisitionDepartmentName }}</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="下达日期" prop="issueDate" width="100" align="center" />
  52. <el-table-column label="操作" width="240" align="center" fixed="right">
  53. <template #default="scope">
  54. <el-button link type="success" icon="View" @click="handleCheckMarterialInfo(scope.row)">领料信息
  55. </el-button>
  56. <el-button :disabled="!(
  57. queryParams.deptId == scope.row.requisitionDepartmentId
  58. ) || scope.row.totalLotNumber == scope.row.lotTotalNumber
  59. " link type="primary" icon="Postcard" @click="handleAddSubDetail(scope.row)"
  60. v-hasPermi="['business:productionBatch:add']">投产
  61. </el-button>
  62. <el-button v-if="scope.row.lotTotalNumber && scope.row.lotTotalNumber >0" v-hasPermi="['business:productionBatch:check']" link type="warning" icon="Search" @click="handleCheckLotInfo(scope.row)">批次信息
  63. </el-button>
  64. <!-- <el-button
  65. icon="edit"
  66. link
  67. type="warning"
  68. @click="handleUpdateProduction(scope.row)"
  69. >编辑</el-button
  70. > -->
  71. </template>
  72. </el-table-column>
  73. </el-table>
  74. </div>
  75. </div>
  76. </section>
  77. <!-- 分页 -->
  78. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
  79. v-model:limit="queryParams.pageSize" @pagination="getProductionPlanDetail" />
  80. <section class="list-part-container row-container" style="flex: 1">
  81. <section class="list-part-container" style="flex: 4">
  82. <!-- 下边页面开始 -->
  83. <!-- 搜索区 -->
  84. <el-form class="list-search-container" :inline="true">
  85. <el-form-item class="section-title" label="生产子计划" />
  86. </el-form>
  87. <div class="el-table-container">
  88. <div class="el-table-inner-container">
  89. <el-table ref="subDetailsTable" v-loading="subDetailsLoading" :data="subList" highlight-current-row
  90. height="100%">
  91. <el-table-column type="index" label="行号" width="50" align="center" />
  92. <el-table-column label="生产计划单号" prop="productionPlanNo" width="110" align="center" />
  93. <el-table-column label="产品描述" prop="productDescription" align="center" />
  94. <el-table-column label="首序投产量" prop="productionQuantity" width="80" align="center" />
  95. <el-table-column label="首序投产批数" prop="lotNumber" width="100" align="center">
  96. <template #default="scope">
  97. <el-input-number v-if="scope.row.editStatus" v-model="scope.row.lotNumber" placeholder="当前投产批数"
  98. :controls="false" :precision="0" :min="0" :max="scope.row.totalLotNumber" align="center" />
  99. <span v-else>{{ scope.row.lotNumber }}</span>
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="下达日期" prop="issuanceDate" width="120" align="center">
  103. <template #default="scope">
  104. <el-date-picker v-if="scope.row.editStatus" clearable v-model="scope.row.issuanceDate" type="date"
  105. value-format="YYYY-MM-DD" placeholder="请选择实际开始 时间" />
  106. <span v-else>{{ scope.row.issuanceDate }}</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="操作" width="150" align="center" v-if="flag">
  110. <template #default="scope">
  111. <el-button v-if="!scope.row.editStatus" icon="edit" link type="warning"
  112. @click="handleShowSubDetailDialog(scope.row)" v-hasPermi="['business:productionBatch:edit']">编辑
  113. </el-button>
  114. <el-button v-if="!scope.row.editStatus" icon="delete" link type="danger"
  115. @click="handleDelSubDetail(scope.row)" v-hasPermi="['business:productionBatch:remove']">删除
  116. </el-button>
  117. </template>
  118. </el-table-column>
  119. </el-table>
  120. </div>
  121. </div>
  122. </section>
  123. </section>
  124. <!-- 投产表单 -->
  125. <production-lot-form ref="productionRef" @handleSaveSuccess="handleFresh()" />
  126. <!-- 领料信息弹窗 -->
  127. <check-material ref="checkMaterialRef" />
  128. <lot-info ref="lotInfoRef" @handleSaveSuccess="handleFresh()" />
  129. <!-- 工艺版本变更弹窗
  130. <production-dialog
  131. ref="productionDetailRef"
  132. @handleUpdateSuccess="handleFresh()"
  133. /> -->
  134. </div>
  135. </template>
  136. <script setup name="ProductionBatch">
  137. import { ref } from "vue";
  138. import { listProductionPlanDetail } from "@/api/business/productionPlanDetail.js";
  139. import {
  140. listPlanDetailSubDetail,
  141. delPlanDetailSubDetail,
  142. getDept,
  143. getLastLotStatus,
  144. } from "@/api/business/planDetailSubDetail.js";
  145. import { updateLotCodeStatus } from "@/api/business/productionPlanDetail.js";
  146. import checkMaterial from "./DialogCheckMaterial";
  147. import productionLotForm from "./form";
  148. import lotInfo from "./lotInfoForm.vue"
  149. // import productionDialog from "./DialogProduction";
  150. const { proxy } = getCurrentInstance();
  151. /** 字典数组区 */
  152. const { lot_code_status_code } = proxy.useDict("lot_code_status_code");
  153. /** 生产计划 */
  154. const currentPlanDetail = ref({});
  155. const detailPlanList = ref([]);
  156. const detailLoading = ref(false);
  157. const total = ref(0);
  158. /** 工段 */
  159. const loading = ref(false);
  160. const deptList = ref([]);
  161. /** 生产子计划 */
  162. const subList = ref([]);
  163. const flag = ref(false);
  164. const subDetailsLoading = ref(false);
  165. /** 查询对象 */
  166. const queryParams = ref({
  167. deptId: "",
  168. keywords: "",
  169. pageNum: 1,
  170. pageSize: 10,
  171. });
  172. /*********************** 方法区 ****************************/
  173. /*********************** 工段 ****************************/
  174. /**
  175. 查询工段
  176. *
  177. */
  178. function getList() {
  179. loading.value = true;
  180. getDept().then((response) => {
  181. deptList.value = response.data;
  182. if (deptList.value.length > 0) {
  183. queryParams.value.deptId = deptList.value[0].value;
  184. getProductionPlanDetail();
  185. }
  186. });
  187. loading.value = false;
  188. }
  189. /**工段下拉框change事件 */
  190. function handleDeptChange() {
  191. handlePlanDetailCurrentChange(currentPlanDetail.value);
  192. }
  193. /*********************** 生产计划 ****************************/
  194. /** 生产子计划进行修改时,对生产计划进行重新查询并选中*/
  195. function handleFresh() {
  196. detailLoading.value = true;
  197. listProductionPlanDetail(queryParams.value).then((res) => {
  198. detailPlanList.value = res.rows;
  199. total.value = res.total;
  200. detailLoading.value = false;
  201. //生产子计划点击
  202. if (detailPlanList.value.length > 0) {
  203. for (var i = 0; i < detailPlanList.value.length; i++) {
  204. if (detailPlanList.value[i].id == currentPlanDetail.value.id) {
  205. var index = i;
  206. break;
  207. }
  208. }
  209. }
  210. proxy.$refs.planDetailTable.setCurrentRow(detailPlanList.value[index]);
  211. });
  212. }
  213. /**查询计划明细 */
  214. function getProductionPlanDetail() {
  215. detailLoading.value = true;
  216. listProductionPlanDetail(queryParams.value).then((res) => {
  217. detailPlanList.value = res.rows;
  218. total.value = res.total;
  219. detailLoading.value = false;
  220. //生产子计划点击
  221. if (detailPlanList.value.length > 0) {
  222. proxy.$refs.planDetailTable.setCurrentRow(detailPlanList.value[0]);
  223. }
  224. });
  225. }
  226. /** 生产计划搜索按钮操作 */
  227. function handleQueryProductionPlanDetail() {
  228. queryParams.value.pageNum = 1;
  229. getProductionPlanDetail();
  230. }
  231. // //打开修改生产计划的版本弹窗
  232. // function handleUpdateProduction(row) {
  233. // proxy.$refs.productionDetailRef.open(row);
  234. // }
  235. //查询生产计划单的领料信息
  236. function handleCheckMarterialInfo(row) {
  237. proxy.$refs.checkMaterialRef.open(row);
  238. }
  239. /** 生产计划明细 current-change 事件 */
  240. function handlePlanDetailCurrentChange(row) {
  241. if (row) {
  242. currentPlanDetail.value = row;
  243. //领料部门是当前工段时,有操作列进行修改删除
  244. if (
  245. currentPlanDetail.value.requisitionDepartmentId ==
  246. queryParams.value.deptId
  247. ) {
  248. flag.value = true;
  249. } else {
  250. flag.value = false;
  251. }
  252. subDetailsLoading.value = true;
  253. listPlanDetailSubDetail({
  254. productionPlanDetailId: row.id,
  255. deptId: queryParams.value.deptId,
  256. }).then((res) => {
  257. subList.value = res.rows;
  258. subDetailsLoading.value = false;
  259. });
  260. } else {
  261. subList.value = [];
  262. }
  263. }
  264. /*********************** 生产子计划 ****************************/
  265. /**新增按钮生产子计划 */
  266. function handleAddSubDetail(row) {
  267. /**创建一个空的对象,将生产计划中的数据赋值给子计划数据 */
  268. const newDetail = {};
  269. newDetail.productionPlanId = row.productionPlanId;
  270. newDetail.productionPlanDetailId = row.id;
  271. newDetail.productionPlanNo = row.productionPlanNo;
  272. newDetail.lineNumber = row.lineNumber
  273. //生产计划总投产量
  274. newDetail.productionQuantityTotal = row.productionQuantity;
  275. newDetail.productId = row.productId;
  276. newDetail.productDescription = row.productDescription;
  277. //生产计划单批量
  278. newDetail.oneLotQuantity = row.oneLotQuantity;
  279. newDetail.deptId = queryParams.value.deptId;
  280. //生产计划总批数
  281. newDetail.totalLotNumber = row.totalLotNumber;
  282. newDetail.technologicalProcessId = row.technologicalProcessId;
  283. newDetail.technologyVersion = row.technologyVersion;
  284. //子计划累计投产量
  285. newDetail.pickUpQuantity = row.pickUpQuantity;
  286. //子计划累计投产批数
  287. newDetail.lotTotalNumber = row.lotTotalNumber;
  288. //生产计划尾批数
  289. newDetail.lastLotQuantity = row.lastLotQuantity;
  290. //新增尾批状态默认为否
  291. newDetail.lastLotStatus = 0;
  292. //新增状态
  293. newDetail.status = false;
  294. //新增时查询生产子计划数据
  295. getLastLotStatus(row.id).then((response) => {
  296. if (response.code == 200) {
  297. //如果为true,生产子计划已有尾批
  298. newDetail.lastLot = response.data;
  299. proxy.$refs.productionRef.open(newDetail);
  300. }
  301. });
  302. }
  303. /** 修改 生产子计划 事件 */
  304. function handleShowSubDetailDialog(row) {
  305. //生产计划单批量
  306. row.oneLotQuantity = currentPlanDetail.value.oneLotQuantity;
  307. //子计划累计投产量
  308. row.pickUpQuantity = currentPlanDetail.value.pickUpQuantity;
  309. //子计划累计投产批数
  310. row.lotTotalNumber = currentPlanDetail.value.lotTotalNumber;
  311. //生产计划总投产量
  312. row.productionQuantityTotal = currentPlanDetail.value.productionQuantity;
  313. //生产计划总批数
  314. row.totalLotNumber = currentPlanDetail.value.totalLotNumber;
  315. //生产计划尾批数
  316. row.lastLotQuantity = currentPlanDetail.value.lastLotQuantity;
  317. //生产计划id
  318. row.productionPlanDetailId = currentPlanDetail.value.id;
  319. //编辑状态
  320. row.status = true;
  321. //判断已投产的生产子计划是否包含尾批
  322. getLastLotStatus(currentPlanDetail.value.id).then((response) => {
  323. if (response.code == 200) {
  324. //如果为true,生产子计划已有尾批
  325. row.lastLot = response.data;
  326. proxy.$refs.productionRef.open(row);
  327. }
  328. });
  329. }
  330. //查看计划单批次
  331. function handleCheckLotInfo(row) {
  332. proxy.$refs.lotInfoRef.open(row)
  333. }
  334. /** 删除子计划事件 */
  335. function handleDelSubDetail(row) {
  336. const _ids = row.id;
  337. var subInfo = subList.value.filter((item) => !item.id.includes(_ids));
  338. proxy.$modal
  339. .confirm("是否确认删除选中的数据项?")
  340. .then(function () {
  341. return delPlanDetailSubDetail(_ids);
  342. })
  343. .then(() => {
  344. //如果该生产计划没有生产子计划了,改变生产计划的批号状态
  345. if (subInfo.length == 0) {
  346. updateLotCodeStatus({
  347. id: currentPlanDetail.value.id,
  348. lotCodeStatusCode: "NA",
  349. }).then((res) => { });
  350. }
  351. handleFresh();
  352. proxy.$modal.msgSuccess("删除成功!");
  353. })
  354. .catch(() => { });
  355. }
  356. onMounted(() => {
  357. // getProductionPlanDetail();
  358. getList();
  359. });
  360. </script>
  361. <style scoped>
  362. .list-search-container-child .el-form-item {
  363. /* 修改样式 */
  364. margin-right: 10px;
  365. }
  366. </style>