luotong.vue 34 KB

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