index.vue 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311
  1. <template>
  2. <div class="app-container" style="width: 100%;">
  3. <el-tabs type="border-card" @tab-click="tabClick" v-model="selectedWorkshop">
  4. <!--南车间-->
  5. <el-tab-pane label="南车间计划" name="南车间">
  6. <!--表格-->
  7. <el-table
  8. :data="tableData"
  9. ref="tableRef"
  10. :span-method="spanMethod2">
  11. <el-table-column prop="machineId" fixed label="机台号" header-align="center" align="center" width="111px" ></el-table-column>
  12. <el-table-column prop="productType" fixed label="产品类别" header-align="center" align="center" width="111.2px"></el-table-column>
  13. <el-table-column label="在机产品" header-align="center" >
  14. <el-table-column prop="productTypeName" fixed label="产品类型" header-align="center" align="center" width="111.2px"></el-table-column>
  15. <el-table-column prop="currentColorCode" label="色号" header-align="center" width="90px" align="center"></el-table-column>
  16. <el-table-column prop="currentSpecification" label="规格" header-align="center" width="90px" align="center"></el-table-column>
  17. <el-table-column prop="currentLotNumber" label="批号" header-align="center" width="90px" align="center"></el-table-column>
  18. <el-table-column prop="currentSpindleCount" label="锭数" header-align="center" width="90px" align="center"></el-table-column>
  19. <el-table-column prop="startTime" label="上机时间" header-align="center" width="90px" align="center"></el-table-column>
  20. <el-table-column prop="plannedEndTime" label="下机时间" header-align="center" width="90px" align="center"></el-table-column>
  21. </el-table-column>
  22. <!-- <el-table-column label="待上机产品" header-align="center" align="center">-->
  23. <!-- <el-table-column prop="djCurrentColorCode" label="色号" header-align="center" align="center"></el-table-column>-->
  24. <!-- <el-table-column prop="djCurrentSpecification" label="规格" header-align="center" align="center"></el-table-column>-->
  25. <!-- <el-table-column prop="djNumber" label="数量" header-align="center" align="center"></el-table-column>-->
  26. <!-- <el-table-column prop="djCurrentLotNumber" label="原丝批号" header-align="center" align="center"></el-table-column>-->
  27. <!-- </el-table-column>-->
  28. <el-table-column prop="listOfPendingProduction" label="待生产产品列表" header-align="center" align="center" >
  29. <template slot-scope="scope">
  30. <div v-if="scope.row.listOfPendingProduction">
  31. <span v-for="(item, index) in scope.row.listOfPendingProduction.split(',')">
  32. {{ item }},
  33. <br v-if="(index + 1) % 5 === 0 && index !== scope.row.listOfPendingProduction.split(',').length - 1" />
  34. </span>
  35. </div>
  36. </template>
  37. </el-table-column>
  38. <el-table-column fixed="right" label="操作" header-align="center" align="center" width="150px" >
  39. <template slot-scope="scope">
  40. <el-dropdown>
  41. <el-button type="primary">
  42. 操作
  43. <i class="el-icon-arrow-down el-icon--right"></i>
  44. </el-button>
  45. <el-dropdown-menu slot="dropdown">
  46. <el-dropdown-item @click.native.prevent="handleAddPlan(scope.row)">新增计划</el-dropdown-item>
  47. <el-dropdown-item @click.native.prevent="handleEditPlan(scope.row)">修改计划</el-dropdown-item>
  48. <el-dropdown-item @click.native.prevent="handleStopProductionLine(scope.row)">机台状态</el-dropdown-item>
  49. </el-dropdown-menu>
  50. </el-dropdown>
  51. </template>
  52. </el-table-column>
  53. </el-table>
  54. <!--新增计划弹窗-->
  55. <el-dialog title="南车间新增计划" :visible.sync="nanInsertDialogTableVisible" width="1200px">
  56. <el-table :data="tableData2" @row-click.self="handleRowClick">
  57. <el-table-column prop="productId" label="产品" header-align="center" align="center" width="150px">
  58. <template v-slot:default="scope">
  59. <el-select v-model="scope.row.productId" placeholder="请选择待排产产品" @change="selectedChangeDate(scope.row,scope.row.productId)">
  60. <el-option v-for="product in productsInfo" :key="product.id" :label="product.productName" :value="product.id" ></el-option>
  61. </el-select>
  62. </template>
  63. </el-table-column>
  64. <el-table-column prop="currentColorCode" label="色号" header-align="center" align="center">
  65. <template v-slot:default="scope">
  66. <!-- 如果当前行正在编辑,则显示输入框 -->
  67. <el-input v-if="scope.row.isEditing" disabled="disabled" v-model="scope.row.currentColorCode" placeholder="请输入色号" @blur.stop.prevent="handleInputBlur(scope.row)" ></el-input>
  68. <!-- 否则显示普通文本 -->
  69. <span v-else>{{ scope.row.currentColorCode }}</span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column prop="currentSpecification" label="规格" header-align="center" align="center">
  73. <template v-slot:default="scope">
  74. <!-- 如果当前行正在编辑,则显示输入框 -->
  75. <el-input v-if="scope.row.isEditing" disabled="disabled" v-model="scope.row.currentSpecification" placeholder="请输入规格" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  76. <!-- 否则显示普通文本 -->
  77. <span v-else>{{ scope.row.currentSpecification }}</span>
  78. </template>
  79. </el-table-column>
  80. <el-table-column prop="productType" label="产品类别" header-align="center" align="center" width="100px">
  81. <template v-slot:default="scope">
  82. <el-select v-model="scope.row.productType" placeholder="请选择产品类别" >
  83. <el-option v-for="product in productTypeList" :key="product.value" :label="product.lable" :value="product.value" ></el-option>
  84. </el-select>
  85. </template>
  86. </el-table-column>
  87. <el-table-column prop="currentLotNumber" label="批号" header-align="center" align="center">
  88. <template v-slot:default="scope">
  89. <el-input v-if="scope.row.isEditing" :disabled="isDisabled" v-model="scope.row.currentLotNumber" placeholder="请输入批号" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  90. <span v-else>{{ scope.row.currentLotNumber }}</span>
  91. </template>
  92. </el-table-column>
  93. <el-table-column prop="currentSpindleCount" label="锭数" header-align="center" align="center">
  94. <template v-slot:default="scope">
  95. <el-input v-if="scope.row.isEditing" v-model="scope.row.currentSpindleCount" placeholder="请输入锭数" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  96. <span v-else>{{ scope.row.currentSpindleCount }}</span>
  97. </template>
  98. </el-table-column>
  99. <el-table-column prop="djNumber" label="数量" header-align="center" align="center">
  100. <template v-slot:default="scope">
  101. <el-input v-if="scope.row.isEditing" v-model="scope.row.number" placeholder="请输入数量" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  102. <span v-else>{{ scope.row.number }}</span>
  103. </template>
  104. </el-table-column>
  105. <el-table-column prop="startTime" label="上机时间" header-align="center" align="center">
  106. <template v-slot:default="scope">
  107. <el-input v-if="scope.row.isEditing" v-model="scope.row.startTime" placeholder="请输入上机时间" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  108. <span v-else>{{ scope.row.startTime }}</span>
  109. </template>
  110. </el-table-column>
  111. <el-table-column prop="plannedEndTime" label="计划下机时间" header-align="center" align="center">
  112. <template v-slot:default="scope">
  113. <el-input v-if="scope.row.isEditing" :ref="'input'+scope.$index" v-model="scope.row.plannedEndTime" placeholder="请输入计划下机时间" @blur="handleInputBlur(scope.row)">></el-input>
  114. <span v-else>{{ scope.row.plannedEndTime }}</span>
  115. </template>
  116. </el-table-column>
  117. <el-table-column prop="planStatus" label="计划状态" header-align="center" align="center" width="100px">
  118. <template v-slot:default="scope">
  119. <el-select v-model="scope.row.planStatus" placeholder="计划状态">
  120. <el-option v-for="stateItem in stateList0" :key="stateItem.id" :label="stateItem.name" :value="stateItem.id" ></el-option>
  121. </el-select>
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="操作">
  125. <template slot-scope="scope">
  126. <el-button
  127. size="mini"
  128. type="danger"
  129. @click.stop.prevent="handleDelete(scope.$index, scope.row)">删除</el-button>
  130. </template>
  131. </el-table-column>
  132. </el-table>
  133. <el-button type="primary" style="width: 100%;margin-top: 30px" @click="addEditableRow">新增计划产品</el-button>
  134. <span slot="footer" class="dialog-footer">
  135. <el-button @click="nanInsertDialogTableVisible = false">取 消</el-button>
  136. <el-button type="primary" @click="addPlanInfo">确 定</el-button>
  137. </span>
  138. </el-dialog>
  139. <!--修改计划弹窗-->
  140. <el-dialog title="修改计划" :visible.sync="nanUpdateDialogTableVisible" width="1400px">
  141. <!--查询条件-->
  142. <el-form ref="form" :model="formData" label-width="80px" :inline="true">
  143. <el-form-item label="产品类别:">
  144. <el-select v-model="formData.productType" placeholder="请选择产品类别">
  145. <el-option v-for="product in productTypeList" :key="product.value" :label="product.lable" :value="product.value" ></el-option>
  146. </el-select>
  147. </el-form-item>
  148. <el-form-item label="计划状态:">
  149. <el-select v-model="formData.planStatus" placeholder="请选择计划状态">
  150. <el-option v-for="stateListItem in stateList2" :key="product.id" :label="stateListItem.name" :value="stateListItem.id" ></el-option>
  151. </el-select>
  152. </el-form-item>
  153. <el-form-item>
  154. <el-button type="primary" @click="onSubmit">查询</el-button>
  155. <el-button @click="reset">重置</el-button>
  156. </el-form-item>
  157. </el-form>
  158. <!--表格-->
  159. <el-table :data="tableData2" @row-click.self="handleRowClick">
  160. <el-table-column prop="productId" label="产品" header-align="center" align="center" width="150px">
  161. <template slot-scope="scope">
  162. {{ getProductChineseName(scope.row.productId) }}
  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="currentSpecification" label="规格" header-align="center" align="center">
  174. <template v-slot:default="scope">
  175. <!-- 如果当前行正在编辑,则显示输入框 -->
  176. <el-input v-if="scope.row.isEditing" disabled="disabled" v-model="scope.row.currentSpecification" placeholder="请输入规格" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  177. <!-- 否则显示普通文本 -->
  178. <span v-else>{{ scope.row.currentSpecification }}</span>
  179. </template>
  180. </el-table-column>
  181. <el-table-column prop="productType" label="产品类别" header-align="center" align="center" width="100px">
  182. <template v-slot:default="scope">
  183. <el-select v-model="scope.row.productType" placeholder="请选择产品类别" >
  184. <el-option v-for="product in productTypeList" :key="product.value" :label="product.lable" :value="product.value" ></el-option>
  185. </el-select>
  186. </template>
  187. </el-table-column>
  188. <el-table-column prop="currentLotNumber" label="批号" header-align="center" align="center">
  189. <template v-slot:default="scope">
  190. <el-input v-if="scope.row.isEditing" disabled="disabled" v-model="scope.row.currentLotNumber" placeholder="请输入批号" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  191. <span v-else>{{ scope.row.currentLotNumber }}</span>
  192. </template>
  193. </el-table-column>
  194. <el-table-column prop="currentSpindleCount" label="锭数" header-align="center" align="center">
  195. <template v-slot:default="scope">
  196. <el-input v-if="scope.row.isEditing" v-model="scope.row.currentSpindleCount" placeholder="请输入锭数" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  197. <span v-else>{{ scope.row.currentSpindleCount }}</span>
  198. </template>
  199. </el-table-column>
  200. <el-table-column prop="number" label="数量" header-align="center" align="center">
  201. <template v-slot:default="scope">
  202. <el-input v-if="scope.row.isEditing" v-model="scope.row.number" placeholder="请输入数量" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  203. <span v-else>{{ scope.row.number }}</span>
  204. </template>
  205. </el-table-column>
  206. <el-table-column prop="startTime" label="上机时间" header-align="center" align="center">
  207. <template v-slot:default="scope">
  208. <el-input v-if="scope.row.isEditing" v-model="scope.row.startTime" placeholder="请输入上机时间" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  209. <span v-else>{{ scope.row.startTime }}</span>
  210. </template>
  211. </el-table-column>
  212. <el-table-column prop="plannedEndTime" label="计划下机时间" header-align="center" align="center">
  213. <template v-slot:default="scope">
  214. <el-input v-if="scope.row.isEditing" :ref="'input'+scope.$index" v-model="scope.row.plannedEndTime" placeholder="请输入计划下机时间" @blur="handleInputBlur(scope.row)">></el-input>
  215. <span v-else>{{ scope.row.plannedEndTime }}</span>
  216. </template>
  217. </el-table-column>
  218. <el-table-column prop="planStatus" label="计划状态" header-align="center" align="center" width="100px">
  219. <template v-slot:default="scope">
  220. <!--上机变停机待机-->
  221. <el-select v-if="scope.row.planStatus==1" v-model="scope.row.planStatus" placeholder="计划状态">
  222. <el-option v-for="stateItem in stateList1" :key="stateItem.id" :label="stateItem.name" :value="stateItem.id" ></el-option>
  223. </el-select>
  224. <!--待机可以上机-->
  225. <el-select v-if="scope.row.planStatus==0" v-model="scope.row.planStatus" placeholder="计划状态" >
  226. <el-option v-for="stateItem in stateList0" :key="stateItem.id" :label="stateItem.name" :value="stateItem.id" ></el-option>
  227. </el-select>
  228. <!--停机变上机-->
  229. <el-select v-if="scope.row.planStatus==2" v-model="scope.row.planStatus" placeholder="计划状态" >
  230. <el-option v-for="stateItem in stateList2" :key="stateItem.id" :label="stateItem.name" :value="stateItem.id" ></el-option>
  231. </el-select>
  232. </template>
  233. </el-table-column>
  234. <el-table-column label="操作" align="center" width="200px">
  235. <template slot-scope="scope">
  236. <el-button
  237. size="mini"
  238. type="danger"
  239. @click.stop.prevent="updateStatus(scope.$index, scope.row)">更新状态</el-button>
  240. <el-button
  241. size="mini"
  242. type="danger"
  243. @click.stop.prevent="deletePlan(scope.$index, scope.row)">删除</el-button>
  244. </template>
  245. </el-table-column>
  246. </el-table>
  247. <!--操作按钮-->
  248. <span slot="footer" class="dialog-footer">
  249. <el-button @click="nanUpdateDialogTableVisible = false">取 消</el-button>
  250. <el-button type="primary" @click="nanUpdateDialogTableVisible = false">确 定</el-button>
  251. </span>
  252. </el-dialog>
  253. </el-tab-pane>
  254. <!--北车间-->
  255. <el-tab-pane label="北车间计划" name="北车间">
  256. <!--表格-->
  257. <el-table
  258. :data="tableData"
  259. ref="tableRef"
  260. :span-method="spanMethod2">
  261. <el-table-column prop="machineId" fixed label="机台号" header-align="center" align="center" width="111px" ></el-table-column>
  262. <el-table-column prop="productType" fixed label="产品类别" header-align="center" align="center" width="111.2px"></el-table-column>
  263. <el-table-column label="在机产品" header-align="center" >
  264. <el-table-column prop="productTypeName" fixed label="产品类型" header-align="center" align="center" width="111.2px"></el-table-column>
  265. <el-table-column prop="currentColorCode" label="色号" header-align="center" width="90px" align="center"></el-table-column>
  266. <el-table-column prop="currentSpecification" label="规格" header-align="center" width="90px" align="center"></el-table-column>
  267. <el-table-column prop="currentLotNumber" label="批号" header-align="center" width="90px" align="center"></el-table-column>
  268. <el-table-column prop="currentSpindleCount" label="锭数" header-align="center" width="90px" align="center"></el-table-column>
  269. <el-table-column prop="startTime" label="上机时间" header-align="center" width="90px" align="center"></el-table-column>
  270. <el-table-column prop="plannedEndTime" label="下机时间" header-align="center" width="90px" align="center"></el-table-column>
  271. </el-table-column>
  272. <!-- <el-table-column label="待上机产品" header-align="center" align="center">-->
  273. <!-- <el-table-column prop="djCurrentColorCode" label="色号" header-align="center" align="center"></el-table-column>-->
  274. <!-- <el-table-column prop="djCurrentSpecification" label="规格" header-align="center" align="center"></el-table-column>-->
  275. <!-- <el-table-column prop="djNumber" label="数量" header-align="center" align="center"></el-table-column>-->
  276. <!-- <el-table-column prop="djCurrentLotNumber" label="原丝批号" header-align="center" align="center"></el-table-column>-->
  277. <!-- </el-table-column>-->
  278. <el-table-column prop="listOfPendingProduction" label="待生产产品列表" header-align="center" align="center" >
  279. <template slot-scope="scope">
  280. <div v-if="scope.row.listOfPendingProduction">
  281. <div v-for="(item, index) in scope.row.listOfPendingProduction.split(',')">
  282. {{ item }}
  283. <span v-if="(index + 1) % 5 === 0 && index !== scope.row.listOfPendingProduction.split(',').length - 1">,</span>
  284. <br v-if="(index + 1) % 5 === 0 && index !== scope.row.listOfPendingProduction.split(',').length - 1" />
  285. </div>
  286. </div>
  287. </template>
  288. </el-table-column>
  289. <el-table-column fixed="right" label="操作" header-align="center" align="center" width="150px" >
  290. <template slot-scope="scope">
  291. <el-dropdown>
  292. <el-button type="primary">
  293. 操作
  294. <i class="el-icon-arrow-down el-icon--right"></i>
  295. </el-button>
  296. <el-dropdown-menu slot="dropdown">
  297. <el-dropdown-item @click.native.prevent="handleAddPlan(scope.row)">新增计划</el-dropdown-item>
  298. <el-dropdown-item @click.native.prevent="handleEditPlan(scope.row)">修改计划</el-dropdown-item>
  299. <el-dropdown-item @click.native.prevent="handleStopProductionLine(scope.row)">机台状态</el-dropdown-item>
  300. </el-dropdown-menu>
  301. </el-dropdown>
  302. </template>
  303. </el-table-column>
  304. </el-table>
  305. <!--新增计划弹窗-->
  306. <el-dialog title="北车间新增计划" :visible.sync="beiInsertDialogTableVisible" width="1200px">
  307. <el-table :data="tableData2" @row-click.self="handleRowClick">
  308. <!-- <el-table-column prop="salesmanId" label="业务员" header-align="center" align="center" width="100px">-->
  309. <!-- <template v-slot:default="scope">-->
  310. <!-- <el-select v-model="scope.row.salesmanId" placeholder="请选择业务员" @change="selectedSalesmanItem(scope.row,scope.row.salesmanId)">-->
  311. <!-- <el-option v-for="salesmanItem in salesmanInfo" :key="salesmanItem.saleNo" :label="salesmanItem.salesman" :value="salesmanItem.saleNo" ></el-option>-->
  312. <!-- </el-select>-->
  313. <!-- </template>-->
  314. <!-- </el-table-column>-->
  315. <el-table-column prop="productId" label="产品" header-align="center" align="center" width="150px">
  316. <template v-slot:default="scope">
  317. <el-select v-model="scope.row.productId" placeholder="请选择待排产产品" @change="selectedChangeDate(scope.row,scope.row.productId)">
  318. <el-option v-for="product in productsInfo" :key="product.id" :label="product.productName" :value="product.id" ></el-option>
  319. </el-select>
  320. </template>
  321. </el-table-column>
  322. <el-table-column prop="currentColorCode" label="色号" header-align="center" align="center">
  323. <template v-slot:default="scope">
  324. <!-- 如果当前行正在编辑,则显示输入框 -->
  325. <el-input v-if="scope.row.isEditing" disabled="disabled" v-model="scope.row.currentColorCode" placeholder="请输入色号" @blur.stop.prevent="handleInputBlur(scope.row)" ></el-input>
  326. <!-- 否则显示普通文本 -->
  327. <span v-else>{{ scope.row.currentColorCode }}</span>
  328. </template>
  329. </el-table-column>
  330. <el-table-column prop="currentSpecification" label="规格" header-align="center" align="center">
  331. <template v-slot:default="scope">
  332. <!-- 如果当前行正在编辑,则显示输入框 -->
  333. <el-input v-if="scope.row.isEditing" disabled="disabled" v-model="scope.row.currentSpecification" placeholder="请输入规格" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  334. <!-- 否则显示普通文本 -->
  335. <span v-else>{{ scope.row.currentSpecification }}</span>
  336. </template>
  337. </el-table-column>
  338. <el-table-column prop="productType" label="产品类别" header-align="center" align="center" width="100px">
  339. <template v-slot:default="scope">
  340. <el-select v-model="scope.row.productType" placeholder="请选择产品类别" >
  341. <el-option v-for="product in productTypeList" :key="product.value" :label="product.lable" :value="product.value" ></el-option>
  342. </el-select>
  343. </template>
  344. </el-table-column>
  345. <el-table-column prop="currentLotNumber" label="批号" header-align="center" align="center">
  346. <template v-slot:default="scope">
  347. <el-input v-if="scope.row.isEditing" :disabled="isDisabled" v-model="scope.row.currentLotNumber" placeholder="请输入批号" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  348. <span v-else>{{ scope.row.currentLotNumber }}</span>
  349. </template>
  350. </el-table-column>
  351. <el-table-column prop="currentSpindleCount" label="锭数" header-align="center" align="center">
  352. <template v-slot:default="scope">
  353. <el-input v-if="scope.row.isEditing" v-model="scope.row.currentSpindleCount" placeholder="请输入锭数" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  354. <span v-else>{{ scope.row.currentSpindleCount }}</span>
  355. </template>
  356. </el-table-column>
  357. <el-table-column prop="number" label="数量" header-align="center" align="center">
  358. <template v-slot:default="scope">
  359. <el-input v-if="scope.row.isEditing" v-model="scope.row.number" placeholder="请输入数量" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  360. <span v-else>{{ scope.row.number }}</span>
  361. </template>
  362. </el-table-column>
  363. <el-table-column prop="startTime" label="上机时间" header-align="center" align="center">
  364. <template v-slot:default="scope">
  365. <el-input v-if="scope.row.isEditing" v-model="scope.row.startTime" placeholder="请输入上机时间" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  366. <span v-else>{{ scope.row.startTime }}</span>
  367. </template>
  368. </el-table-column>
  369. <el-table-column prop="plannedEndTime" label="计划下机时间" header-align="center" align="center">
  370. <template v-slot:default="scope">
  371. <el-input v-if="scope.row.isEditing" :ref="'input'+scope.$index" v-model="scope.row.plannedEndTime" placeholder="请输入计划下机时间" @blur="handleInputBlur(scope.row)">></el-input>
  372. <span v-else>{{ scope.row.plannedEndTime }}</span>
  373. </template>
  374. </el-table-column>
  375. <el-table-column prop="planStatus" label="计划状态" header-align="center" align="center" width="100px">
  376. <template v-slot:default="scope">
  377. <el-select v-model="scope.row.planStatus" placeholder="计划状态" >
  378. <el-option v-for="stateItem in stateList0" :key="stateItem.id" :label="stateItem.name" :value="stateItem.id" ></el-option>
  379. </el-select>
  380. </template>
  381. </el-table-column>
  382. <el-table-column label="操作" >
  383. <template slot-scope="scope">
  384. <el-button
  385. size="mini"
  386. type="danger"
  387. @click.stop.prevent="handleDelete(scope.$index, scope.row)">删除</el-button>
  388. </template>
  389. </el-table-column>
  390. </el-table>
  391. <el-button type="primary" style="width: 100%;margin-top: 30px" @click="addEditableRow">新增计划产品</el-button>
  392. <span slot="footer" class="dialog-footer">
  393. <el-button @click="beiInsertDialogTableVisible = false">取 消</el-button>
  394. <el-button type="primary" @click="addPlanInfo">确 定</el-button>
  395. </span>
  396. </el-dialog>
  397. <!--修改计划弹窗-->
  398. <el-dialog title="北车间修改计划" :visible.sync="beiUpdateDialogTableVisible" width="1200px">
  399. <!--查询条件-->
  400. <el-form ref="form" :model="formData" label-width="80px" :inline="true">
  401. <el-form-item label="产品类别:">
  402. <el-select v-model="formData.productType" placeholder="请选择产品类别">
  403. <el-option v-for="(product,index) in productTypeList" :key="index" :label="product.lable" :value="product.value" ></el-option>
  404. </el-select>
  405. </el-form-item>
  406. <el-form-item label="计划状态:">
  407. <el-select v-model="formData.planStatus" placeholder="请选择计划状态">
  408. <el-option v-for="stateListItem in stateList2" :key="product.id" :label="stateListItem.name" :value="stateListItem.id" ></el-option>
  409. </el-select>
  410. </el-form-item>
  411. <el-form-item>
  412. <el-button type="primary" @click="onSubmit">查询</el-button>
  413. <el-button @click="reset">重置</el-button>
  414. </el-form-item>
  415. </el-form>
  416. <!--表格-->
  417. <el-table :data="tableData2" @row-click.self="handleRowClick">
  418. <el-table-column prop="productId" label="产品" header-align="center" align="center" width="150px">
  419. <template slot-scope="scope">
  420. {{ getProductChineseName(scope.row.productId) }}
  421. </template>
  422. </el-table-column>
  423. <el-table-column prop="currentColorCode" label="色号" header-align="center" align="center">
  424. <template v-slot:default="scope">
  425. <!-- 如果当前行正在编辑,则显示输入框 -->
  426. <el-input v-if="scope.row.isEditing" disabled="disabled" v-model="scope.row.currentColorCode" placeholder="请输入色号" @blur.stop.prevent="handleInputBlur(scope.row)" ></el-input>
  427. <!-- 否则显示普通文本 -->
  428. <span v-else>{{ scope.row.currentColorCode }}</span>
  429. </template>
  430. </el-table-column>
  431. <el-table-column prop="currentSpecification" label="规格" header-align="center" align="center">
  432. <template v-slot:default="scope">
  433. <!-- 如果当前行正在编辑,则显示输入框 -->
  434. <el-input v-if="scope.row.isEditing" disabled="disabled" v-model="scope.row.currentSpecification" placeholder="请输入规格" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  435. <!-- 否则显示普通文本 -->
  436. <span v-else>{{ scope.row.currentSpecification }}</span>
  437. </template>
  438. </el-table-column>
  439. <el-table-column prop="productType" label="产品类别" header-align="center" align="center" width="100px">
  440. <template v-slot:default="scope">
  441. <el-select v-model="scope.row.productType" placeholder="请选择产品类别">
  442. <el-option v-for="product in productTypeList" :key="product.value" :label="product.lable" :value="product.value" ></el-option>
  443. </el-select>
  444. </template>
  445. </el-table-column>
  446. <el-table-column prop="currentLotNumber" label="批号" header-align="center" align="center">
  447. <template v-slot:default="scope">
  448. <el-input v-if="scope.row.isEditing" disabled="disabled" v-model="scope.row.currentLotNumber" placeholder="请输入批号" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  449. <span v-else>{{ scope.row.currentLotNumber }}</span>
  450. </template>
  451. </el-table-column>
  452. <el-table-column prop="currentSpindleCount" label="锭数" header-align="center" align="center">
  453. <template v-slot:default="scope">
  454. <el-input v-if="scope.row.isEditing" v-model="scope.row.currentSpindleCount" placeholder="请输入锭数" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  455. <span v-else>{{ scope.row.currentSpindleCount }}</span>
  456. </template>
  457. </el-table-column>
  458. <el-table-column prop="number" label="数量" header-align="center" align="center">
  459. <template v-slot:default="scope">
  460. <el-input v-if="scope.row.isEditing" v-model="scope.row.number" placeholder="请输入数量" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  461. <span v-else>{{ scope.row.number }}</span>
  462. </template>
  463. </el-table-column>
  464. <el-table-column prop="startTime" label="上机时间" header-align="center" align="center">
  465. <template v-slot:default="scope">
  466. <el-input v-if="scope.row.isEditing" v-model="scope.row.startTime" placeholder="请输入上机时间" @blur.stop.prevent="handleInputBlur(scope.row)">></el-input>
  467. <span v-else>{{ scope.row.startTime }}</span>
  468. </template>
  469. </el-table-column>
  470. <el-table-column prop="plannedEndTime" label="计划下机时间" header-align="center" align="center">
  471. <template v-slot:default="scope">
  472. <el-input v-if="scope.row.isEditing" :ref="'input'+scope.$index" v-model="scope.row.plannedEndTime" placeholder="请输入计划下机时间" @blur="handleInputBlur(scope.row)">></el-input>
  473. <span v-else>{{ scope.row.plannedEndTime }}</span>
  474. </template>
  475. </el-table-column>
  476. <el-table-column prop="planStatus" label="计划状态" header-align="center" align="center" width="100px">
  477. <template v-slot:default="scope">
  478. <!--上机变停机待机-->
  479. <el-select v-if="scope.row.planStatus==1" v-model="scope.row.planStatus" placeholder="计划状态" >
  480. <el-option v-for="stateItem in stateList1" :key="stateItem.id" :label="stateItem.name" :value="stateItem.id" ></el-option>
  481. </el-select>
  482. <!--待机可以上机-->
  483. <el-select v-if="scope.row.planStatus==0" v-model="scope.row.planStatus" placeholder="计划状态" >
  484. <el-option v-for="stateItem in stateList0" :key="stateItem.id" :label="stateItem.name" :value="stateItem.id" ></el-option>
  485. </el-select>
  486. <!--停机变上机-->
  487. <el-select v-if="scope.row.planStatus==2" v-model="scope.row.planStatus" placeholder="计划状态" >
  488. <el-option v-for="stateItem in stateList2" :key="stateItem.id" :label="stateItem.name" :value="stateItem.id" ></el-option>
  489. </el-select>
  490. </template>
  491. </el-table-column>
  492. <el-table-column label="操作" align="center" width="200px">
  493. <template slot-scope="scope">
  494. <el-button
  495. size="mini"
  496. type="danger"
  497. @click.stop.prevent="updateStatus(scope.$index, scope.row)">更新状态</el-button>
  498. <el-button
  499. size="mini"
  500. type="danger"
  501. @click.stop.prevent="deletePlan(scope.$index, scope.row)">删除</el-button>
  502. </template>
  503. </el-table-column>
  504. </el-table>
  505. <span slot="footer" class="dialog-footer">
  506. <el-button @click="beiUpdateDialogTableVisible = false">取 消</el-button>
  507. <el-button type="primary" @click="beiUpdateDialogTableVisible = false">确 定</el-button>
  508. </span>
  509. </el-dialog>
  510. </el-tab-pane>
  511. <!--停机弹窗-->
  512. <el-dialog title="修改机台状态" :visible.sync="modifyMachineStatus" width="500px">
  513. <el-form :model="modifyMachineStatusFrom" ref="modifyMachineStatusFrom" label-width="100px" class="demo-ruleForm">
  514. <el-form-item label="机台状态" prop="type">
  515. <el-checkbox-group v-model="modifyMachineStatusFrom.type">
  516. <el-checkbox label="1" name="type">A面停机</el-checkbox>
  517. <el-checkbox label="2" name="type">B面停机</el-checkbox>
  518. </el-checkbox-group>
  519. </el-form-item>
  520. <el-form-item>
  521. <el-button type="primary" @click="confirmStopProductionLine">确定</el-button>
  522. <el-button @click="tjqx">取消</el-button>
  523. </el-form-item>
  524. </el-form>
  525. </el-dialog>
  526. </el-tabs>
  527. </div>
  528. </template>
  529. <script>
  530. import {
  531. ammunitionPlanInfo,
  532. getProductsInfo,
  533. removeBombLoadingPlan,
  534. getMaterielInfo,
  535. addMaterielInfo,
  536. getProductsAll,
  537. getAllPlanListByMachineId,
  538. getAllPlanListByProductTypeAndStatus,
  539. updatePlanOne,
  540. whetherTheFeederIsShutDown,
  541. updateLineStates,
  542. getIsTheOrderProductProduced,
  543. getJtIsTheOrderProductProduced,
  544. getCurrentProductionLineSuperior,
  545. updateSpinningInfoPlanOne
  546. } from "@/api/plan/paln.js";
  547. export default {
  548. data() {
  549. return {
  550. modifyMachineStatusFrom:{
  551. type: [],
  552. },
  553. modifyMachineStatus:false,
  554. //选中的是那个车间
  555. selectedWorkshop:"南车间",
  556. tableData:[],
  557. isDisabled:true,
  558. form: {
  559. product:"",
  560. },
  561. previousMachineId: undefined,
  562. currentRowspan: 1,
  563. prevRow: {},
  564. tableData2: [],
  565. nanInsertDialogTableVisible:false,
  566. nanUpdateDialogTableVisible:false,
  567. beiInsertDialogTableVisible:false,
  568. beiUpdateDialogTableVisible:false,
  569. editingRowIndex: -1,
  570. lastEditLine:0,
  571. queryParams:{ productionLineDepartment:"加弹部",
  572. productionLineWorkshop:"南车间"},
  573. isEditLine:false,
  574. productsInfo:[],
  575. salesmanInfo:[],
  576. product:{},
  577. materiel:{},
  578. // 机台号
  579. machineId:"",
  580. macId:"",//机台id
  581. // 待机/上机/停产
  582. stateList0:[
  583. {"id":0,"name":"待机"},
  584. {"id":1,"name":"上机"},
  585. ],
  586. stateList1:[
  587. {"id":0,"name":"待机"},
  588. {"id":2,"name":"停机"},
  589. {"id":1,"name":"上机"},
  590. ],
  591. stateList2:[
  592. {"id":0,"name":"待机"},
  593. {"id":2,"name":"停机"},
  594. {"id":1,"name":"上机"},
  595. ],
  596. formData:{
  597. updateSelectedProductCategory:"",
  598. updateSelectedProductState:""
  599. },
  600. // 产品类别
  601. productTypeList:[{value:"A面",lable:"A面"},{value:"B面",lable:"B面"}],
  602. }
  603. },
  604. mounted() {
  605. // 得到排产计划信息
  606. this.getAmmunitionPlanInfo();
  607. },
  608. methods: {
  609. tjqx(){
  610. this.modifyMachineStatus=false;
  611. },
  612. getProductChineseName(productId) {
  613. return this.productsInfo.find(product => product.id == productId).productName;
  614. },
  615. //删除计划
  616. deletePlan($index,row){
  617. console.log(row)
  618. //判断当前计划是否已经投产
  619. getJtIsTheOrderProductProduced({"id":row.id}).then(resp=>{
  620. if(resp.data.length>0){
  621. this.$message({message: '当前计划订单产品在生产中已经不能删除', type: 'warning'});
  622. return;//证明有在上级的产品--zhi能有一个上级产品
  623. }
  624. removeBombLoadingPlan(row.id).then(res=>{
  625. if(res.code==200){
  626. this.$message({
  627. message: '删除成功',
  628. type: 'success'
  629. });
  630. }else{
  631. this.$message({message:"删除失败",type: 'error'})
  632. }
  633. this.onSubmit();
  634. this.getAmmunitionPlanInfo();
  635. })
  636. });
  637. },
  638. //打开修改机台信息
  639. handleStopProductionLine(row){
  640. this.modifyMachineStatus=true;
  641. this.machineId=row.machineId;
  642. this.macId=row.macId;//机台id
  643. //查询当前机台A、面B面的状态
  644. whetherTheFeederIsShutDown(this.macId).then(res=>{
  645. this.modifyMachineStatusFrom.type=res.data;
  646. })
  647. },
  648. //确认修改产线信息
  649. confirmStopProductionLine(){
  650. // console.log(this.modifyMachineStatusFrom.type);
  651. if(this.modifyMachineStatusFrom.type.length==0){
  652. this.modifyMachineStatusFrom.type.push("3")
  653. }
  654. //更改状态
  655. updateLineStates(this.macId,this.modifyMachineStatusFrom.type.join(",")).then(res=>{
  656. if(res.code==200){
  657. this.$message({
  658. message: '修改状态成功',
  659. type: 'success'
  660. });
  661. }else{
  662. this.$message({message:"修改状态成功",type: 'error'})
  663. }
  664. this.modifyMachineStatus=false;
  665. this.getAmmunitionPlanInfo();
  666. })
  667. // //如果为空代表都不停机
  668. // if(this.modifyMachineStatusFrom.type.length<=0){
  669. // this.modifyMachineStatus=false;
  670. // //发送请求删除,A面-timestampRandomCode="停机" B-timestampRandomCode="停机"的数据、并把所有上机产品的状态改为上机
  671. // return;
  672. // }
  673. // // 包含1A停机---插入一条 timestampRandomCode=停机,状态为停机的数据
  674. // if (this.modifyMachineStatusFrom.type.includes("1")) {
  675. // //查询当前机台A、面B面的状态
  676. // whetherTheFeederIsShutDown(this.machineId).then(res=>{
  677. // //后台没有虚拟的假数据,就插入
  678. // if(!res.data.includes("1")){
  679. // console.log('数组中不包含数字 1');
  680. // //新增一条数据,
  681. // let aStopInfo= {
  682. // currentColorCode: '1',
  683. // //产品规格
  684. // currentSpecification: '1',
  685. // currentLotNumber: '1',
  686. // currentSpindleCount: '1',
  687. // number: '1',
  688. // productType:'A面',
  689. // startTime: '1',
  690. // plannedEndTime:'1',
  691. // planStatus:2,
  692. // productId:'1',
  693. // machineId:this.machineId,
  694. // salesmanId:'1',
  695. // timestampRandomCode:"停机",
  696. // }
  697. // let aStoptableList=[];
  698. // aStoptableList.push(aStopInfo)
  699. // //时间戳
  700. // let data={
  701. // //机台号
  702. // machineId: this.machineId,
  703. // //计划信息
  704. // detailsOfTheRefuelingPlans: aStoptableList
  705. // }
  706. // //添加计划信息
  707. // addMaterielInfo(data).then(response => {
  708. // if (response.code == 200) {
  709. // this.$message({
  710. // message: '停机成功',
  711. // type: 'success'
  712. // });
  713. // this.getAmmunitionPlanInfo();
  714. // //最后把弹窗关掉
  715. // this.nanInsertDialogTableVisible=false
  716. // //更改订单投产信息的批号,
  717. // } else {
  718. // this.$message({
  719. // message: '停机失败,请联系管理员',
  720. // type: 'error'
  721. // });
  722. // //最后把弹窗关掉
  723. // this.nanInsertDialogTableVisible=false
  724. // }
  725. // });
  726. // }
  727. // })
  728. // }
  729. // if(this.modifyMachineStatusFrom.type.includes("2")) {
  730. // whetherTheFeederIsShutDown(this.machineId).then(res=>{
  731. // if(!res.data.includes("2")) {
  732. // console.log('数组中不包含数字2');
  733. // //新增一条数据,
  734. // let aStopInfo= {
  735. // currentColorCode: '1',
  736. // //产品规格
  737. // currentSpecification: '1',
  738. // currentLotNumber: '1',
  739. // currentSpindleCount: '1',
  740. // number: '1',
  741. // productType:'B面',
  742. // startTime: '1',
  743. // plannedEndTime:'1',
  744. // planStatus:2,
  745. // productId:'1',
  746. // machineId:this.machineId,
  747. // salesmanId:'1',
  748. // timestampRandomCode:"停机",
  749. // }
  750. // let aStoptableList=[];
  751. // aStoptableList.push(aStopInfo)
  752. // //时间戳
  753. // let data={
  754. // //机台号
  755. // machineId: this.machineId,
  756. // //计划信息
  757. // detailsOfTheRefuelingPlans: aStoptableList
  758. // }
  759. // //添加计划信息
  760. // addMaterielInfo(data).then(response => {
  761. // if (response.code == 200) {
  762. // this.$message({
  763. // message: '停机成功',
  764. // type: 'success'
  765. // });
  766. // this.getAmmunitionPlanInfo();
  767. // //最后把弹窗关掉
  768. // this.nanInsertDialogTableVisible=false
  769. // //更改订单投产信息的批号,
  770. // } else {
  771. // this.$message({
  772. // message: '停机失败,请联系管理员',
  773. // type: 'error'
  774. // });
  775. // //最后把弹窗关掉
  776. // this.nanInsertDialogTableVisible=false
  777. // }
  778. // });
  779. // }
  780. // })
  781. // }
  782. },
  783. // 查询排产信息
  784. getAmmunitionPlanInfo() {
  785. ammunitionPlanInfo(this.queryParams).then((response) => {
  786. this.tableData = response.data
  787. });
  788. },
  789. // 合并单元格
  790. spanMethod2({ row, column, rowIndex, columnIndex }) {
  791. //第二列合并
  792. if (columnIndex === 1) {
  793. if(row.productType == null) {
  794. return;
  795. }
  796. const prevRow2 = this.tableData[rowIndex - 1]; // 上一行数据
  797. let nextRow2 = this.tableData[rowIndex + 1]; // 下一行数据
  798. // 当上一行的数据(machineId和productType)等于当前行数据时,当前行单元格隐藏
  799. if (
  800. prevRow2 &&
  801. prevRow2.machineId === row.machineId &&
  802. prevRow2.productType === row.productType
  803. ) {
  804. return { rowspan: 0, colspan: 0 };
  805. } else {
  806. // 反之,则循环判断若下一行数据(machineId和productType)等于当前行数据,则当前行开始进行合并单元格
  807. let countRowspan2 = 1; // 用于合并计数多少单元格
  808. while (
  809. nextRow2 &&
  810. nextRow2.machineId === row.machineId &&
  811. nextRow2.productType === row.productType
  812. ) {
  813. nextRow2 = this.tableData[++countRowspan2 + rowIndex];
  814. }
  815. if (countRowspan2 > 1) {
  816. return { rowspan: countRowspan2, colspan: 1 };
  817. }
  818. }
  819. }
  820. //待生产列表
  821. if (columnIndex === 9) {
  822. const prevRow2 = this.tableData[rowIndex - 1] //上一行数据
  823. let nextRow2 = this.tableData[rowIndex + 1] //下一行数据
  824. // 当上一行的数据等于当前行数据时,当前行单元格隐藏
  825. if(row.listOfPendingProduction==null||row.listOfPendingProduction==undefined|| row.listOfPendingProduction==""){
  826. return;
  827. }
  828. if (prevRow2 &&
  829. prevRow2.machineId === row.machineId &&
  830. prevRow2.productType === row.productType
  831. ) {
  832. return { rowspan: 0, colspan: 0 }
  833. } else {
  834. // 反之,则循环判断若下一行数据等于当前行数据,则当前行开始进行合并单元格
  835. let countRowspan2 = 1 //用于合并计数多少单元格
  836. while (nextRow2 &&
  837. nextRow2.listOfPendingProduction === row.listOfPendingProduction&&
  838. nextRow2.machineId === row.machineId &&
  839. nextRow2.productType === row.productType
  840. ) {
  841. nextRow2 = this.tableData[++countRowspan2 + rowIndex]
  842. }
  843. if (countRowspan2 > 1) {
  844. return { rowspan: countRowspan2, colspan: 1 }
  845. }
  846. }
  847. }
  848. //合并最后一列操作列
  849. const lastColumnIndex = this.$refs.tableRef.store.states.columns.length - 1; // 获取表格最后一列的索引
  850. if (columnIndex === lastColumnIndex && column.label === '操作') { // 判断是否为最后一列且标签为'操作'
  851. const machineIdColumnIndex = 0; // 机台号列的索引假定为0
  852. const currentMachineId = row.machineId;
  853. let countRowspan = 1;
  854. const prevRow = this.tableData[rowIndex - 1];
  855. if (prevRow && prevRow.machineId === currentMachineId) {
  856. return { rowspan: 0, colspan: 0 };
  857. } else {
  858. let nextRow = this.tableData[rowIndex + 1];
  859. while (
  860. nextRow &&
  861. nextRow.machineId === currentMachineId
  862. ) {
  863. nextRow = this.tableData[++countRowspan + rowIndex];
  864. }
  865. if (countRowspan > 1) {
  866. return { rowspan: countRowspan, colspan: 1 };
  867. }
  868. }
  869. }
  870. //第一列机台号合并
  871. if (columnIndex === 0) {
  872. //定义需要合并的列字段,有哪些列需要合并,就自定义添加字段即可
  873. const fields = ['machineId']
  874. // 当前行的数据
  875. const cellValue = row[column.property]
  876. let countRowspan = 1 //用于合并计数多少单元格
  877. // 判断只合并定义字段的列数据
  878. if (cellValue && fields.includes(column.property)) {
  879. const prevRow = this.tableData[rowIndex - 1] //上一行数据
  880. let nextRow = this.tableData[rowIndex + 1] //下一行数据
  881. // 当上一行的数据等于当前行数据时,当前行单元格隐藏
  882. if (prevRow && prevRow[column.property] === cellValue) {
  883. return { rowspan: 0, colspan: 0 }
  884. } else {
  885. // 反之,则循环判断若下一行数据等于当前行数据,则当前行开始进行合并单元格
  886. let countRowspan = 1 //用于合并计数多少单元格
  887. while (nextRow && nextRow[column.property] === cellValue) {
  888. nextRow = this.tableData[++countRowspan + rowIndex]
  889. }
  890. if (countRowspan > 1) {
  891. return { rowspan: countRowspan, colspan: 1 }
  892. }
  893. }
  894. }
  895. }
  896. },
  897. getProductsInfo() {
  898. getProductsInfo("JT-").then((response) => {
  899. this.productsInfo = response.data;
  900. this.productsInfo.forEach(item => {
  901. item.productName = item.productName+"—"+item.materieEncoding+item.materieColorNumber
  902. });
  903. })
  904. },
  905. // 下拉框数据改变查询色号批号信息
  906. selectedChangeDate(row,selectedProduct) {
  907. //选择的那个销售产品
  908. this.product = this.productsInfo.find(product => product.id === selectedProduct);
  909. this.form.product=selectedProduct;
  910. //通过母粒编码查询到对应的母粒信息
  911. let queryParams = {
  912. "materielCode": this.product.colourNumber
  913. }
  914. //得到对应的母粒信息
  915. getMaterielInfo(queryParams).then((response) => {
  916. if (response.data!=null) {
  917. this.materiel = response.data;
  918. //色号 母粒编码+色号
  919. row.currentColorCode = this.materiel.materieEncoding+"("+this.materiel.materieColorNumber+")";
  920. }
  921. });
  922. //isDisabled(有批号就用,没批号就自己输入)
  923. if(this.product.lotNumber!=undefined&&this.product.lotNumber!=""){
  924. row.currentLotNumber=this.product.lotNumber;
  925. this.isDisabled=true;
  926. }else {
  927. this.isDisabled=false;
  928. row.currentLotNumber="";
  929. }
  930. //产品规格
  931. row.currentSpecification= this.product.productSpecifications;
  932. //销售单编号(以前打算存的是业务员信息后来存的是销售单编号)
  933. row.salesmanId=this.product.saleOrderNo;
  934. //数量
  935. row.number=this.product.productNumber;
  936. // console.log(this.product,'ddddddddddddddd')
  937. },
  938. // 新增计划产品信息
  939. handleAddPlan(row) {
  940. //查询当前机台A、面B面的状态(这个不用改,因为这个是唯一的)
  941. whetherTheFeederIsShutDown(row.macId).then(res=>{
  942. this.modifyMachineStatusFrom.type=res.data;
  943. if(this.modifyMachineStatusFrom.type.includes("2")&&this.modifyMachineStatusFrom.type.includes("1")){
  944. this.$message({
  945. message: 'AB都已停机请更改机台状态',
  946. type: 'warning'
  947. });
  948. return;
  949. }else {
  950. if(this.modifyMachineStatusFrom.type.includes("1")){
  951. this.productTypeList=[]
  952. this.productTypeList.push({value:"B面",lable:"B面"})
  953. }
  954. if(this.modifyMachineStatusFrom.type.includes("2")){
  955. this.productTypeList=[]
  956. this.productTypeList.push({value:"A面",lable:"A面"})
  957. }
  958. if(this.modifyMachineStatusFrom.type.length<=0){
  959. this.productTypeList=[]
  960. this.productTypeList.push({value:"A面",lable:"A面"})
  961. this.productTypeList.push({value:"B面",lable:"B面"})
  962. }
  963. //否则就打开弹窗添加计划
  964. if(this.selectedWorkshop=="南车间"){
  965. this.nanInsertDialogTableVisible = true
  966. }else{
  967. this.beiInsertDialogTableVisible = true
  968. }
  969. //查询可以添加的产品信息
  970. this.getProductsInfo();
  971. //清空添加的数组对象
  972. this.tableData2=[]
  973. //先清空
  974. this.machineId=""
  975. //当前操作机台号
  976. this.machineId=row.machineId;
  977. this.macId=row.macId;
  978. }
  979. })
  980. },
  981. // tab栏点击切换
  982. tabClick(tab, event) {
  983. // console.log('当前点击的标签名称:', tab.name);
  984. this.selectedWorkshop = tab.name;
  985. // productionLineName getProductionLineNo productionLineDepartment productionLineWorkshop
  986. this.queryParams.productionLineWorkshop = tab.name;
  987. this.getAmmunitionPlanInfo();
  988. },
  989. // 删除行
  990. handleDelete(index, row) {
  991. // console.log(index,row)
  992. // this.tableData2[a];
  993. this.tableData2.splice(index, 1);
  994. // 把上一编辑行置回-1
  995. this.editingRowIndex = -1;
  996. },
  997. // 点击编辑行
  998. handleRowClick(row) {
  999. // this.isEditLine = true;
  1000. // // alert(this.lastEditLine+"编辑行")
  1001. // //找到当前行的编辑索引
  1002. // var rowIndex = this.tableData2.indexOf(row);
  1003. //
  1004. // if (this.lastEditLine != 0 &&
  1005. // this.editingRowIndex !== rowIndex &&
  1006. // this.editingRowIndex !== -1 &&
  1007. // !this.isRowFilled(this.tableData2[this.lastEditLine])) {
  1008. // this.$message({
  1009. // message: '请先完成上一条数据的填写',
  1010. // type: 'warning'
  1011. // });
  1012. // return;
  1013. // }
  1014. // //编辑索引不等于当前编辑行索引
  1015. // if (this.editingRowIndex !== rowIndex) {
  1016. // // alert(this.editingRowIndex);
  1017. // if (this.editingRowIndex !== -1) {
  1018. // //把当前行变成不可编辑的
  1019. // this.tableData2[this.editingRowIndex].isEditing = false;
  1020. // }
  1021. // //把当前行变成可编辑的
  1022. // row.isEditing = true;
  1023. // this.editingRowIndex = rowIndex;
  1024. // }
  1025. },
  1026. // 光标失去焦点变成不可编辑
  1027. handleInputBlur(row) {
  1028. // let rowIndex = this.tableData2.indexOf(row);
  1029. // //编辑索引不等于当前编辑行索引
  1030. // if (this.editingRowIndex !== rowIndex) {
  1031. // if (this.isRowFilled(row)) {
  1032. // row.isEditing = false;
  1033. // //对于整个表格来说
  1034. // this.isEditLine = false;
  1035. // //当前编辑行置为-1
  1036. // this.editingRowIndex = -1;
  1037. // }
  1038. // }
  1039. },
  1040. // 检查行是否填写完毕的示例方法
  1041. isRowFilled(row) {
  1042. return row.currentSpecification &&
  1043. row.currentSpindleCount &&
  1044. row.currentColorCode &&
  1045. row.productType &&
  1046. row.currentLotNumber &&
  1047. row.number &&
  1048. row.startTime &&
  1049. row.plannedEndTime;
  1050. },
  1051. // 新增一行标记为可编辑
  1052. addEditableRow() {
  1053. // 检查当前编辑行是否已填写完毕
  1054. if(this.tableData2.length!=0){
  1055. if (this.editingRowIndex !== -1 && !this.isRowFilled(this.tableData2[this.editingRowIndex])) {
  1056. this.$message({
  1057. message: '请先完成上一条数据的填写',
  1058. type: 'warning'
  1059. });
  1060. return;
  1061. }
  1062. //新增行之前先让以前的行不能编辑
  1063. this.tableData2.forEach(item => {
  1064. item.isEditing = false;
  1065. })
  1066. }
  1067. this.tableData2.push({
  1068. currentColorCode: '',
  1069. currentSpecification: '',
  1070. currentLotNumber: '',
  1071. currentSpindleCount: '',
  1072. number: '',
  1073. startTime: '',
  1074. plannedEndTime:'',
  1075. planStatus:0,
  1076. productId:'',
  1077. salesmanId:'',
  1078. isEditing: true // 标记为正在编辑状态
  1079. });
  1080. this.editingRowIndex = this.tableData2.length - 1; // 更新当前编辑的行索引
  1081. this.lastEditLine = this.tableData2.length - 1
  1082. },
  1083. // 添加计划
  1084. addPlanInfo(){
  1085. if(this.tableData2.length>0){
  1086. var flag=true;
  1087. this.tableData2.forEach(item=>{
  1088. if(!this.isRowFilled(item)){
  1089. this.$message({
  1090. message: '请先完善表格数据',
  1091. type: 'warning'
  1092. });
  1093. flag=false
  1094. }
  1095. })
  1096. if(flag){
  1097. const datatime=Date.now()+this.machineId;
  1098. //处理表格数据
  1099. this.tableData2.forEach(item=>{
  1100. item.timestampRandomCode=datatime;
  1101. item.machineId=this.machineId;
  1102. })
  1103. //时间戳
  1104. let data={
  1105. //机台号
  1106. machineId: this.machineId,
  1107. macId:this.macId,
  1108. timestampRandomCode:datatime,
  1109. //计划信息
  1110. detailsOfTheRefuelingPlans: this.tableData2
  1111. }
  1112. //添加计划信息
  1113. addMaterielInfo(data).then(response => {
  1114. if (response.code == 200) {
  1115. this.$message({
  1116. message: '添加成功',
  1117. type: 'success'
  1118. });
  1119. this.getAmmunitionPlanInfo();
  1120. //最后把弹窗关掉
  1121. this.nanInsertDialogTableVisible = false
  1122. this.beiInsertDialogTableVisible = false
  1123. //更改订单投产信息的批号,
  1124. } else {
  1125. this.$message({
  1126. message: '添加失败',
  1127. type: 'error'
  1128. });
  1129. this.nanInsertDialogTableVisible = false
  1130. this.beiInsertDialogTableVisible = false
  1131. //最后把弹窗关掉
  1132. }
  1133. });
  1134. }
  1135. }else {
  1136. this.$message({
  1137. message: '请先添加表格数据',
  1138. type: 'warning'
  1139. });
  1140. return;
  1141. }
  1142. },
  1143. // 修改产品计划
  1144. handleEditPlan(row) {
  1145. //已经在待机列表了,isNull过滤掉了
  1146. getProductsAll(row.macId).then((response) => {
  1147. this.productsInfo = response.data;
  1148. this.productsInfo.forEach(item => {
  1149. item.productName = item.productName+"—"+item.materieEncoding+item.materieColorNumber
  1150. });
  1151. this.tableData2=[];
  1152. //弹窗
  1153. if(this.selectedWorkshop=="南车间"){
  1154. this.nanUpdateDialogTableVisible = true
  1155. }else{
  1156. this.beiUpdateDialogTableVisible = true
  1157. }
  1158. //先清空--当前操作机台号
  1159. this.machineId=""
  1160. this.machineId=row.machineId;
  1161. this.macId=row.macId;
  1162. //查询当前机台下的计划信息
  1163. getAllPlanListByMachineId(this.macId).then((response) => {
  1164. //得到生产中,停产的,待产的
  1165. response.data.forEach(item => {
  1166. item.isEditing=false;
  1167. item.planStatus=parseInt(item.planStatus);
  1168. item.productId=parseInt(item.productId)
  1169. })
  1170. this.tableData2=response.data;
  1171. // console.log( this.tableData2)
  1172. })
  1173. })
  1174. },
  1175. //重置按钮
  1176. reset(){
  1177. this.tableData2=[];
  1178. //弹窗
  1179. if(this.selectedWorkshop=="南车间"){
  1180. this.nanUpdateDialogTableVisible = true
  1181. }else{
  1182. this.beiUpdateDialogTableVisible = true
  1183. }
  1184. console.log(this.machineId,"dddd")
  1185. getAllPlanListByMachineId(this.machineId).then((response) => {
  1186. //得到生产中,停产的,待产的
  1187. response.data.forEach(item => {
  1188. item.isEditing=false;
  1189. item.planStatus=parseInt(item.planStatus);
  1190. item.productId=parseInt(item.productId)
  1191. })
  1192. this.tableData2=response.data;
  1193. // console.log( this.tableData2)
  1194. // 在数据加载完成后,手动触发每个行的第一个下拉框的 change 事件
  1195. this.$nextTick(() => {
  1196. // 获取第一个业务员选择框(假设表格只有一行)
  1197. for (let i = 0; i < this.tableData2.length; i++) {
  1198. const firstSalesmanSelect = this.$refs['salesmanSelect'+i];
  1199. // 触发 change 事件
  1200. if (firstSalesmanSelect) {
  1201. firstSalesmanSelect.$emit('change', {
  1202. target: {value: "ddd"},
  1203. });
  1204. }
  1205. }
  1206. });
  1207. })
  1208. },
  1209. //弹窗里边的点击查询
  1210. onSubmit(){
  1211. this.formData.macId=this.macId;
  1212. getAllPlanListByProductTypeAndStatus(this.formData).then(response => {
  1213. //得到生产中,停产的,待产的
  1214. response.data.forEach(item => {
  1215. item.isEditing=false;
  1216. item.planStatus=parseInt(item.planStatus);
  1217. })
  1218. this.tableData2=response.data;
  1219. });
  1220. },
  1221. //更新状态
  1222. updateStatus(ind, row){
  1223. if(!this.isRowFilled(row)){
  1224. this.$message({message: '请完善当前行数据', type: 'warning'});
  1225. return;
  1226. }
  1227. //判断当前计划是否已经投产
  1228. getJtIsTheOrderProductProduced({"id":row.id}).then(resp=>{
  1229. if(resp.data.length>0) {
  1230. this.$message({message: '当前计划订单产品在生产中已经不能修改', type: 'warning'});
  1231. return;//证明有在上级的产品--zhi能有一个上级产品
  1232. }
  1233. //不是投产中就可以更新了.
  1234. updatePlanOne(row).then(response=>{
  1235. if (response.code == 200) {
  1236. this.$message({
  1237. message: '修改成功',
  1238. type: 'success'
  1239. });
  1240. this.getAmmunitionPlanInfo();
  1241. //最后把弹窗关掉
  1242. this.nanInsertDialogTableVisible=false
  1243. this.beiUpdateDialogTableVisible=false
  1244. } else {
  1245. this.$message({
  1246. message: '修改失败',
  1247. type: 'error'
  1248. });
  1249. //最后把弹窗关掉
  1250. this.nanInsertDialogTableVisible=false
  1251. this.beiUpdateDialogTableVisible=false
  1252. }
  1253. })
  1254. })
  1255. }
  1256. }
  1257. }
  1258. </script>
  1259. <style scoped>
  1260. .el-tabs--border-card >>> .el-tabs__content {
  1261. padding: 0 !important;
  1262. }
  1263. .el-table__body-wrapper {
  1264. cursor: grab;
  1265. }
  1266. .el-table__body-wrapper.grabbing {
  1267. cursor: grabbing;
  1268. }
  1269. .container >>> .el-table .cell {
  1270. white-space: pre-line;
  1271. }
  1272. </style>