fankuang.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. <template>
  2. <div class="app-container" style="width: 100%;">
  3. <!--表格-->
  4. <el-table
  5. :data="tableData"
  6. ref="tableRef">
  7. <el-table-column prop="machineId" fixed label="机台号" header-align="center" align="center" width="111px" ></el-table-column>
  8. <el-table-column prop="productionDigit" fixed label="生产位数" header-align="center" align="center" width="111.2px"></el-table-column>
  9. <el-table-column label="在机产品" header-align="center" >
  10. <el-table-column prop="currentColorCode" label="色号" header-align="center" width="90px" align="center"></el-table-column>
  11. <el-table-column prop="currentSpecification" label="规格" header-align="center" width="90px" align="center"></el-table-column>
  12. <el-table-column prop="currentLotNumber" label="批号" header-align="center" width="90px" align="center"></el-table-column>
  13. <el-table-column prop="startTime" label="上机时间" header-align="center" width="90px" align="center"></el-table-column>
  14. <el-table-column prop="plannedEndTime" label="下机时间" header-align="center" width="90px" align="center"></el-table-column>
  15. </el-table-column>
  16. <el-table-column prop="plannedProduction" label="待生产产品列表" header-align="center" align="center" >
  17. <template v-slot:default="scope">
  18. <div v-if="scope.row.plannedProduction && scope.row.plannedProduction.length > 0">
  19. <div v-for="(chunk, chunkIndex) in splitList(scope.row.plannedProduction, 5)" :key="`chunk-${chunkIndex}`">
  20. <span v-for="(item, index) in chunk" :key="`item-${chunkIndex}-${index}`">
  21. {{ item }}, <!-- 替换为实际显示每个产品的代码 -->
  22. </span>
  23. </div>
  24. </div>
  25. <div v-else>
  26. </div>
  27. </template>
  28. </el-table-column>
  29. <el-table-column fixed="right" label="操作" header-align="center" align="center" width="150px" >
  30. <template v-slot:default="scope">
  31. <el-dropdown>
  32. <el-button type="primary">
  33. 操作
  34. <i class="el-icon-arrow-down el-icon--right"></i>
  35. </el-button>
  36. <el-dropdown-menu slot="dropdown">
  37. <el-dropdown-item @click.native.prevent="handleAddPlan(scope.row)">新增计划</el-dropdown-item>
  38. <el-dropdown-item @click.native.prevent="handleEditPlan(scope.row)">修改计划</el-dropdown-item>
  39. </el-dropdown-menu>
  40. </el-dropdown>
  41. </template>
  42. </el-table-column>
  43. </el-table>
  44. <!--新增计划弹窗-->
  45. <el-dialog title="新增计划" :visible.sync="nanInsertDialogTableVisible" width="1200px">
  46. <el-table :data="tableData2" @row-click.self="handleRowClick">
  47. <!-- <el-table-column prop="salesmanId" label="业务员" header-align="center" align="center" width="100px">-->
  48. <!-- <template v-slot:default="scope">-->
  49. <!-- <el-select v-model="scope.row.salesmanId" placeholder="请选择业务员" @change="selectedSalesmanItem(scope.row,scope.row.salesmanId)">-->
  50. <!-- <el-option v-for="salesmanItem in salesmanInfo" :key="salesmanItem.saleNo" :label="salesmanItem.salesman" :value="salesmanItem.saleNo" ></el-option>-->
  51. <!-- </el-select>-->
  52. <!-- </template>-->
  53. <!-- </el-table-column>-->
  54. <el-table-column prop="productId" label="产品" header-align="center" align="center" width="150px">
  55. <template v-slot:default="scope">
  56. <el-select v-model="scope.row.productId" placeholder="请选择待排产产品" @change="selectedChangeDate(scope.row,scope.row.productId)">
  57. <el-option v-for="product in productsInfo" :key="product.id" :label="product.productName" :value="product.id" ></el-option>
  58. </el-select>
  59. </template>
  60. </el-table-column>
  61. <el-table-column prop="currentColorCode" label="色号" header-align="center" align="center">
  62. <template v-slot:default="scope">
  63. <!-- 如果当前行正在编辑,则显示输入框 -->
  64. <el-input v-if="scope.row.isEditing" disabled="disabled" v-model="scope.row.currentColorCode" placeholder="请输入色号" @blur.stop.prevent="handleInputBlur(scope.row)" ></el-input>
  65. <!-- 否则显示普通文本 -->
  66. <span v-else>{{ scope.row.currentColorCode }}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column prop="productionDigit" label="生产位数" header-align="center" align="center">
  70. <template v-slot:default="scope">
  71. <el-input v-if="scope.row.isEditing" v-model="scope.row.productionDigit" placeholder="请输入生产位数" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  72. <span v-else>{{ scope.row.productionDigit }}</span>
  73. </template>
  74. </el-table-column>
  75. <el-table-column prop="currentSpecification" label="规格" header-align="center" align="center">
  76. <template v-slot:default="scope">
  77. <!-- 如果当前行正在编辑,则显示输入框 -->
  78. <el-input v-if="scope.row.isEditing" disabled="disabled" v-model="scope.row.currentSpecification" placeholder="请输入规格" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  79. <!-- 否则显示普通文本 -->
  80. <span v-else>{{ scope.row.currentSpecification }}</span>
  81. </template>
  82. </el-table-column>
  83. <el-table-column prop="currentLotNumber" label="批号" header-align="center" align="center">
  84. <template v-slot:default="scope">
  85. <el-input v-if="scope.row.isEditing" :disabled="isDisabled" v-model="scope.row.currentLotNumber" placeholder="请输入批号" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  86. <span v-else>{{ scope.row.currentLotNumber }}</span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column prop="djNumber" label="数量" header-align="center" align="center">
  90. <template v-slot:default="scope">
  91. <el-input v-if="scope.row.isEditing" v-model="scope.row.number" placeholder="请输入数量" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  92. <span v-else>{{ scope.row.number }}</span>
  93. </template>
  94. </el-table-column>
  95. <el-table-column prop="startTime" label="上机时间" header-align="center" align="center">
  96. <template v-slot:default="scope">
  97. <el-input v-if="scope.row.isEditing" v-model="scope.row.startTime" placeholder="请输入上机时间" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  98. <span v-else>{{ scope.row.startTime }}</span>
  99. </template>
  100. </el-table-column>
  101. <el-table-column prop="plannedEndTime" label="计划下机时间" header-align="center" align="center">
  102. <template v-slot:default="scope">
  103. <el-input v-if="scope.row.isEditing" :ref="'input'+scope.$index" v-model="scope.row.plannedEndTime" placeholder="请输入计划下机时间" @blur="handleInputBlur(scope.row)">></el-input>
  104. <span v-else>{{ scope.row.plannedEndTime }}</span>
  105. </template>
  106. </el-table-column>
  107. <el-table-column prop="planStatus" label="计划状态" header-align="center" align="center" width="100px">
  108. <template v-slot:default="scope">
  109. <el-select v-model="scope.row.planStatus" placeholder="请选择计划状态">
  110. <el-option v-for="stateItem in stateList0" :key="stateItem.id" :label="stateItem.name" :value="stateItem.id" ></el-option>
  111. </el-select>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="操作" align="center">
  115. <template slot-scope="scope">
  116. <el-button
  117. size="mini"
  118. type="danger"
  119. @click.stop.prevent="handleDelete(scope.$index, scope.row)">删除</el-button>
  120. </template>
  121. </el-table-column>
  122. </el-table>
  123. <el-button type="primary" style="width: 100%;margin-top: 30px" @click="addEditableRow">新增计划产品</el-button>
  124. <span slot="footer" class="dialog-footer">
  125. <el-button @click="nanInsertDialogTableVisible = false">取 消</el-button>
  126. <el-button type="primary" @click="addPlanInfo">确 定</el-button>
  127. </span>
  128. </el-dialog>
  129. <!--修改计划弹窗-->
  130. <el-dialog title="修改计划" :visible.sync="nanUpdateDialogTableVisible" width="1200px">
  131. <!--查询条件-->
  132. <el-form ref="form" :model="formData" label-width="80px" :inline="true">
  133. <el-form-item label="计划状态:">
  134. <el-select v-model="formData.planStatus" placeholder="请选择计划状态">
  135. <el-option v-for="stateListItem in stateList2" :key="product.id" :label="stateListItem.name" :value="stateListItem.id" ></el-option>
  136. </el-select>
  137. </el-form-item>
  138. <el-form-item>
  139. <el-button type="primary" @click="onSubmit">查询</el-button>
  140. <el-button @click="reset">重置</el-button>
  141. </el-form-item>
  142. </el-form>
  143. <!--表格-->
  144. <el-table :data="tableData2" @row-click.self="handleRowClick">
  145. <!-- <el-table-column prop="salesmanId" label="业务员" header-align="center" align="center" width="100px">-->
  146. <!-- <template v-slot:default="scope">-->
  147. <!-- <el-select :ref="'salesmanSelect'+scope.$index" v-model="scope.row.salesmanId" placeholder="请选择业务员" @change="selectedSalesmanItem(scope.row,scope.row.salesmanId,scope.$index)">-->
  148. <!-- <el-option v-for="salesmanItem in salesmanInfo" :key="salesmanItem.saleNo" :label="salesmanItem.salesman" :value="salesmanItem.saleNo" ></el-option>-->
  149. <!-- </el-select>-->
  150. <!-- </template>-->
  151. <!-- </el-table-column>-->
  152. <el-table-column prop="productId" label="产品" header-align="center" align="center" width="150px">
  153. <template v-slot:default="scope">
  154. <el-select :ref="'productSelected'+scope.$index" v-model="scope.row.productId" placeholder="请选择待排产产品" @change="selectedChangeDate(scope.row,scope.row.productId)">
  155. <el-option v-for="product in productsInfo" :key="product.id" :label="product.productName" :value="product.id" ></el-option>
  156. </el-select>
  157. </template>
  158. </el-table-column>
  159. <el-table-column prop="productionDigit" label="生产位数" header-align="center" align="center">
  160. <template v-slot:default="scope">
  161. <el-input v-if="scope.row.isEditing" v-model="scope.row.productionDigit" placeholder="请输入生产位数" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  162. <span v-else>{{ scope.row.productionDigit }}</span>
  163. </template>
  164. </el-table-column>
  165. <el-table-column prop="currentColorCode" label="色号" header-align="center" align="center">
  166. <template v-slot:default="scope">
  167. <!-- 如果当前行正在编辑,则显示输入框 -->
  168. <el-input v-if="scope.row.isEditing" disabled="disabled" v-model="scope.row.currentColorCode" placeholder="请输入色号" @blur.stop.prevent="handleInputBlur(scope.row)" ></el-input>
  169. <!-- 否则显示普通文本 -->
  170. <span v-else>{{ scope.row.currentColorCode }}</span>
  171. </template>
  172. </el-table-column>
  173. <el-table-column prop="weishu" label="位数" header-align="center" align="center">
  174. <template v-slot:default="scope">
  175. <!-- 如果当前行正在编辑,则显示输入框 -->
  176. <el-input v-if="scope.row.isEditing" v-model="scope.row.currentColorCode" placeholder="请输入色号" @blur.stop.prevent="handleInputBlur(scope.row)" ></el-input>
  177. <!-- 否则显示普通文本 -->
  178. <span v-else>{{ scope.row.currentColorCode }}</span>
  179. </template>
  180. </el-table-column>
  181. <el-table-column prop="currentSpecification" label="规格" header-align="center" align="center">
  182. <template v-slot:default="scope">
  183. <!-- 如果当前行正在编辑,则显示输入框 -->
  184. <el-input v-if="scope.row.isEditing" disabled="disabled" v-model="scope.row.currentSpecification" placeholder="请输入规格" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  185. <!-- 否则显示普通文本 -->
  186. <span v-else>{{ scope.row.currentSpecification }}</span>
  187. </template>
  188. </el-table-column>
  189. <el-table-column prop="currentLotNumber" label="批号" header-align="center" align="center">
  190. <template v-slot:default="scope">
  191. <el-input v-if="scope.row.isEditing" v-model="scope.row.currentLotNumber" placeholder="请输入批号" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  192. <span v-else>{{ scope.row.currentLotNumber }}</span>
  193. </template>
  194. </el-table-column>
  195. <el-table-column prop="startTime" label="上机时间" header-align="center" align="center">
  196. <template v-slot:default="scope">
  197. <el-input v-if="scope.row.isEditing" v-model="scope.row.startTime" placeholder="请输入上机时间" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  198. <span v-else>{{ scope.row.startTime }}</span>
  199. </template>
  200. </el-table-column>
  201. <el-table-column prop="plannedEndTime" label="计划下机时间" header-align="center" align="center">
  202. <template v-slot:default="scope">
  203. <el-input v-if="scope.row.isEditing" :ref="'input'+scope.$index" v-model="scope.row.plannedEndTime" placeholder="请输入计划下机时间" @blur="handleInputBlur(scope.row)">></el-input>
  204. <span v-else>{{ scope.row.plannedEndTime }}</span>
  205. </template>
  206. </el-table-column>
  207. <el-table-column prop="planStatus" label="计划状态" header-align="center" align="center" width="100px">
  208. <template v-slot:default="scope">
  209. <!--上机变停机待机-->
  210. <el-select v-if="scope.row.planStatus==1" v-model="scope.row.planStatus" placeholder="计划状态" @change="selectedSalesmanItem(scope.row,scope.row.planStatus)">
  211. <el-option v-for="stateItem in stateList1" :key="stateItem.id" :label="stateItem.name" :value="stateItem.id" ></el-option>
  212. </el-select>
  213. <!--待机可以上机-->
  214. <el-select v-if="scope.row.planStatus==0" v-model="scope.row.planStatus" placeholder="计划状态" @change="selectedSalesmanItem(scope.row,scope.row.planStatus)">
  215. <el-option v-for="stateItem in stateList0" :key="stateItem.id" :label="stateItem.name" :value="stateItem.id" ></el-option>
  216. </el-select>
  217. <!--停机变上机-->
  218. <el-select v-if="scope.row.planStatus==2" v-model="scope.row.planStatus" placeholder="计划状态" @change="selectedSalesmanItem(scope.row,scope.row.planStatus)">
  219. <el-option v-for="stateItem in stateList2" :key="stateItem.id" :label="stateItem.name" :value="stateItem.id" ></el-option>
  220. </el-select>
  221. <!--已完成-->
  222. <el-select v-if="scope.row.planStatus==3" v-model="scope.row.planStatus" placeholder="计划状态" @change="selectedSalesmanItem(scope.row,scope.row.planStatus)">
  223. <el-option v-for="stateItem in stateList3" :key="stateItem.id" :label="stateItem.name" :value="stateItem.id" ></el-option>
  224. </el-select>
  225. </template>
  226. </el-table-column>
  227. <el-table-column label="操作" align="center" width="200px">
  228. <template v-slot:default="scope">
  229. <el-button
  230. size="mini"
  231. type="danger"
  232. @click.stop.prevent="updateStatus(scope.$index, scope.row,scope.row.planStatus)">更新状态</el-button>
  233. <el-button
  234. size="mini"
  235. type="danger"
  236. @click.stop.prevent="deletePlan(scope.$index, scope.row)">删除</el-button>
  237. </template>
  238. </el-table-column>
  239. </el-table>
  240. <span slot="footer" class="dialog-footer">
  241. <el-button @click="nanUpdateDialogTableVisible = false">取 消</el-button>
  242. <el-button type="primary" @click="nanUpdateDialogTableVisible = false">确 定</el-button>
  243. </span>
  244. </el-dialog>
  245. </div>
  246. </template>
  247. <script>
  248. import {
  249. getProductsInfo,
  250. getMaterielInfo,
  251. getSalesman,
  252. getSpinningPlanList,
  253. addSpinningPlanList,
  254. getPlanSpinningInfo,
  255. updateSpinningInfoPlanOne, spinningFrameWinding
  256. } from "@/api/plan/paln.js";
  257. export default {
  258. data() {
  259. return {
  260. //
  261. isDisabled:true,
  262. //选中的是那个车间
  263. tableData:[],
  264. form: {
  265. product:"",
  266. },
  267. previousMachineId: undefined,
  268. currentRowspan: 1,
  269. prevRow: {},
  270. tableData2: [],
  271. tableDataStatus: [],
  272. nanInsertDialogTableVisible:false,
  273. nanUpdateDialogTableVisible:false,
  274. beiInsertDialogTableVisible:false,
  275. beiUpdateDialogTableVisible:false,
  276. editingRowIndex: -1,
  277. lastEditLine:0,
  278. isEditLine:false,
  279. productsInfo:[],
  280. salesmanInfo:[],
  281. product:{},
  282. materiel:{},
  283. //机台号
  284. machineId:"",
  285. // 待机/上机/停产
  286. stateList0:[
  287. {"id":0,"name":"待机"},
  288. {"id":1,"name":"上机"},
  289. ],
  290. stateList1:[
  291. {"id":0,"name":"待机"},
  292. {"id":1,"name":"上机"},
  293. {"id":2,"name":"停机"},
  294. {"id":3,"name":"已完成"},
  295. ],
  296. stateList2:[
  297. {"id":0,"name":"待机"},
  298. {"id":2,"name":"停机"},
  299. {"id":1,"name":"上机"},
  300. ],
  301. stateList3:[
  302. {"id":3,"name":"已完成"},
  303. ],
  304. formData:{
  305. updateSelectedProductCategory:"",
  306. updateSelectedProductState:""
  307. },
  308. }
  309. },
  310. mounted() {
  311. // 得到排产计划信息
  312. this.getSpinningPlanList();
  313. // this.getSalesman();
  314. this.getProductsInfo();
  315. },
  316. methods: {
  317. deletePlan($index,row){
  318. console.log(row)
  319. spinningFrameWinding(row.id).then(res=>{
  320. if(res.code==200){
  321. this.$message({
  322. message: '删除成功',
  323. type: 'success'
  324. });
  325. }else{
  326. this.$message({message:"删除失败",type: 'error'})
  327. }
  328. this.onSubmit();
  329. this.getSpinningPlanList();
  330. })
  331. },
  332. //五个显示为一排
  333. splitList(list, chunkSize) {
  334. const chunks = [];
  335. for (let i = 0; i < list.length; i += chunkSize) {
  336. chunks.push(list.slice(i, i + chunkSize));
  337. }
  338. return chunks;
  339. },
  340. // 查询排产信息
  341. getSpinningPlanList() {
  342. getSpinningPlanList({"productionLineDepartment":"翻框部"}).then((response) => {
  343. this.tableData = response.rows
  344. });
  345. },
  346. // //查询产品的业务员信息
  347. // getSalesman() {
  348. // getSalesman().then((response) => {
  349. // this.salesmanInfo = response.data;
  350. // })
  351. // },
  352. // //业务员下拉框切换调用的函数
  353. // selectedSalesmanItem(row,saleNo,index){
  354. // console.log("ccc",index)
  355. // this.getProductsInfo(saleNo,index);
  356. // },
  357. // //待投产的产品数据
  358. // getProductsInfo(saleNo,sy) {
  359. // getProductsInfo(saleNo,sy).then((response) => {
  360. // this.productsInfo = response.data;
  361. // this.productsInfo.forEach(item => {
  362. // item.productName = item.productName+"—"+item.materieEncoding+item.materieColorNumber
  363. // });
  364. // })
  365. // },
  366. getProductsInfo() {
  367. console.log("ddddddddddddddddddddddd")
  368. getProductsInfo().then((response) => {
  369. this.productsInfo = response.data;
  370. this.productsInfo.forEach(item => {
  371. item.productName = item.productName+"—"+item.materieEncoding+item.materieColorNumber
  372. });
  373. })
  374. },
  375. // 下拉框数据改变查询色号批号信息
  376. selectedChangeDate(row,selectedProduct) {
  377. //选择的那个销售产品
  378. console.log(this.productsInfo,"hhhhhh")
  379. this.product = this.productsInfo.find(product => product.id === selectedProduct);
  380. //选择的那个产品
  381. this.form.product=selectedProduct;
  382. //通过母粒编码查询到对应的母粒信息
  383. let queryParams = {
  384. "materielCode": this.product.colourNumber
  385. }
  386. //得到对应的母粒信息
  387. getMaterielInfo(queryParams).then((response) => {
  388. if (response.data!=null) {
  389. this.materiel = response.data;
  390. //色号 母粒编码+色号
  391. row.currentColorCode = this.materiel.materieEncoding+"("+this.materiel.materieColorNumber+")";
  392. }
  393. });
  394. //isDisabled(有批号就用,没批号就自己输入)
  395. if(this.product.lotNumber!=undefined&&this.product.lotNumber!=""){
  396. row.currentLotNumber=this.product.lotNumber;
  397. this.isDisabled=true;
  398. }else {
  399. this.isDisabled=false;
  400. }
  401. //产品规格
  402. row.currentSpecification= this.product.productSpecifications;
  403. //合同号--销售单编号(以前打算存的是业务员信息后来存的是销售单编号)
  404. row.salesmanId=this.product.saleOrderNo;
  405. },
  406. // 新增计划产品信息
  407. handleAddPlan(row) {
  408. this.getProductsInfo();
  409. this.nanInsertDialogTableVisible = true
  410. this.tableData2=[]
  411. //先清空
  412. this.machineId=""
  413. //当前操作机台号
  414. this.machineId=row.machineId;
  415. },
  416. // 删除行
  417. handleDelete(index, row) {
  418. // console.log(index,row)
  419. // this.tableData2[a];
  420. this.tableData2.splice(index, 1);
  421. // 把上一编辑行置回-1
  422. this.editingRowIndex = -1;
  423. },
  424. // 点击编辑行
  425. handleRowClick(row) {
  426. this.isEditLine = true;
  427. //找到当前行的编辑索引
  428. var rowIndex = this.tableData2.indexOf(row);
  429. if (this.lastEditLine != 0 &&
  430. this.editingRowIndex !== rowIndex &&
  431. this.editingRowIndex !== -1 &&
  432. !this.isRowFilled(this.tableData2[this.lastEditLine])) {
  433. this.$message({
  434. message: '请先完成上一条数据的填写',
  435. type: 'warning'
  436. });
  437. return;
  438. }
  439. //编辑索引不等于当前编辑行索引
  440. if (this.editingRowIndex !== rowIndex) {
  441. // alert(this.editingRowIndex);
  442. if (this.editingRowIndex !== -1) {
  443. //把当前行变成不可编辑的
  444. this.tableData2[this.editingRowIndex].isEditing = false;
  445. }
  446. //把当前行变成可编辑的
  447. row.isEditing = true;
  448. this.editingRowIndex = rowIndex;
  449. }
  450. },
  451. // 光标失去焦点变成不可编辑
  452. handleInputBlur(row) {
  453. let rowIndex = this.tableData2.indexOf(row);
  454. //编辑索引不等于当前编辑行索引
  455. if (this.editingRowIndex !== rowIndex) {
  456. if (this.isRowFilled(row)) {
  457. row.isEditing = false;
  458. //对于整个表格来说
  459. this.isEditLine = false;
  460. //当前编辑行置为-1
  461. this.editingRowIndex = -1;
  462. }
  463. }
  464. },
  465. // 检查行是否填写完毕的示例方法
  466. isRowFilled(row) {
  467. return row.currentSpecification && row.productionDigit && row.startTime && row.plannedEndTime;
  468. },
  469. // 新增一行标记为可编辑
  470. addEditableRow() {
  471. // 检查当前编辑行是否已填写完毕
  472. if(this.tableData2.length!=0){
  473. if (this.editingRowIndex !== -1 && !this.isRowFilled(this.tableData2[this.editingRowIndex])) {
  474. this.$message({
  475. message: '请先完成上一条数据的填写',
  476. type: 'warning'
  477. });
  478. return;
  479. }
  480. //新增行之前先让以前的行不能编辑
  481. this.tableData2.forEach(item => {
  482. item.isEditing = false;
  483. })
  484. }
  485. this.tableData2.push({
  486. currentColorCode: '',
  487. currentSpecification: '',
  488. currentLotNumber: '',
  489. productionDigit: '',
  490. startTime: '',
  491. plannedEndTime:'',
  492. planStatus:0,
  493. productId:'',
  494. salesmanId:'',
  495. isEditing: true // 标记为正在编辑状态
  496. });
  497. this.editingRowIndex = this.tableData2.length - 1; // 更新当前编辑的行索引
  498. this.lastEditLine = this.tableData2.length - 1
  499. },
  500. // 添加计划
  501. addPlanInfo(){
  502. const datatime=Date.now()+this.machineId;
  503. //先查询计划表中有没有正在上机的
  504. getPlanSpinningInfo({"machineId":this.machineId,"planStatus":1}).then(response => {
  505. let i=0
  506. //处理表格数据
  507. this.tableData2.forEach(item=>{
  508. item.timestampRandomCode=datatime;
  509. item.machineId=this.machineId;
  510. if(item.planStatus==1){
  511. i++
  512. }
  513. })
  514. if(i>=1&&response.data.length>0){
  515. this.$message({
  516. message: '只能有一个产品的状态为上机',
  517. type: 'warning'
  518. });
  519. return;
  520. }else {
  521. //添加计划信息
  522. addSpinningPlanList(this.tableData2).then(response => {
  523. if (response.code == 200) {
  524. this.$message({
  525. message: '添加成功',
  526. type: 'success'
  527. });
  528. this.getSpinningPlanList();
  529. //最后把弹窗关掉
  530. this.nanInsertDialogTableVisible=false
  531. } else {
  532. this.$message({
  533. message: '添加失败',
  534. type: 'error'
  535. });
  536. //最后把弹窗关掉
  537. this.nanInsertDialogTableVisible=false
  538. }
  539. });
  540. }
  541. });
  542. },
  543. // 修改产品计划
  544. handleEditPlan(row) {
  545. //当前操作机台号
  546. this.machineId=row.machineId;
  547. this.tableData2=[];
  548. //弹窗
  549. this.nanUpdateDialogTableVisible = true
  550. getPlanSpinningInfo({"machineId":row.machineId}).then((response) => {
  551. //得到生产中,停产的,待产的
  552. response.data.forEach(item => {
  553. item.isEditing=false;
  554. item.planStatus=parseInt(item.planStatus);
  555. item.productId=parseInt(item.productId)
  556. })
  557. this.tableData2=response.data;
  558. console.log( this.tableData2)
  559. // 在数据加载完成后,手动触发每个行的第一个下拉框的 change 事件
  560. this.$nextTick(() => {
  561. // 获取第一个业务员选择框(假设表格只有一行)
  562. this.tableDataStatus=[];
  563. for (let i = 0; i < this.tableData2.length; i++) {
  564. const firstSalesmanSelect = this.$refs['salesmanSelect'+i];
  565. this.tableDataStatus.push({"index":i,"planStatus":this.tableData2[i].planStatus})
  566. // console.log(firstSalesmanSelect,11111111)
  567. // 触发 change 事件
  568. if (firstSalesmanSelect) {
  569. firstSalesmanSelect.$emit('change', {
  570. target: {value: "ddd"},
  571. });
  572. }
  573. }
  574. });
  575. })
  576. },
  577. //弹窗里边的点击查询
  578. onSubmit(){
  579. this.formData.machineId=this.machineId;
  580. getPlanSpinningInfo(this.formData).then(response => {
  581. //得到生产中,停产的,待产的
  582. response.data.forEach(item => {
  583. item.isEditing=false;
  584. item.planStatus=parseInt(item.planStatus);
  585. })
  586. this.tableData2=response.data;
  587. });
  588. },
  589. //重置
  590. reset(){
  591. getPlanSpinningInfo({"machineId":this.machineId}).then(response => {
  592. //得到生产中,停产的,待产的
  593. response.data.forEach(item => {
  594. item.isEditing=false;
  595. item.planStatus=parseInt(item.planStatus);
  596. })
  597. this.tableData2=response.data;
  598. });
  599. },
  600. //更新状态
  601. updateStatus(ind, row,planStatus){
  602. const a=planStatus;
  603. console.log( row.planStatus,this.tableDataStatus[ind].planStatus)
  604. if(planStatus==this.tableDataStatus[ind].planStatus){
  605. this.$message({
  606. message: '并未更改状态,不会发送请求',
  607. type: 'warning'
  608. });
  609. return;
  610. }
  611. //先查询计划表中有没有正在上机的
  612. getPlanSpinningInfo({"machineId":this.machineId,"planStatus":planStatus}).then(response => {
  613. let i=0
  614. //处理表格数据
  615. this.tableData2.forEach(item=>{
  616. item.machineId=this.machineId;
  617. if(item.planStatus==1){
  618. i++
  619. }
  620. })
  621. if(i>=1&&response.data.length>0){
  622. this.$message({
  623. message: '只能有一个产品的状态为上机',
  624. type: 'warning'
  625. });
  626. row.planStatus=planStatus;
  627. return;
  628. }else {
  629. updateSpinningInfoPlanOne(row).then(response=>{
  630. if (response.code == 200) {
  631. this.$message({
  632. message: '修改成功',
  633. type: 'success'
  634. });
  635. this.getSpinningPlanList();
  636. this.tableDataStatus=[]
  637. for (let i = 0; i < this.tableData2.length; i++) {
  638. this.tableDataStatus.push({"index": i, "planStatus": this.tableData2[i].planStatus})
  639. }
  640. //最后把弹窗关掉
  641. this.nanInsertDialogTableVisible=false
  642. } else {
  643. this.$message({
  644. message: '修改失败',
  645. type: 'error'
  646. });
  647. //最后把弹窗关掉
  648. this.nanInsertDialogTableVisible=false
  649. }
  650. })
  651. }
  652. });
  653. }
  654. },
  655. computed: {
  656. },
  657. }
  658. </script>
  659. <style scoped>
  660. .el-tabs--border-card >>> .el-tabs__content {
  661. padding: 0 !important;
  662. }
  663. .el-table__body-wrapper {
  664. cursor: grab;
  665. }
  666. .el-table__body-wrapper.grabbing {
  667. cursor: grabbing;
  668. }
  669. </style>