index.vue 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305
  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 in productTypeList" :key="product.value" :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>取消</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, getJtIsTheOrderProductProduced
  543. } from "@/api/plan/paln.js";
  544. export default {
  545. data() {
  546. return {
  547. modifyMachineStatusFrom:{
  548. type: [],
  549. },
  550. modifyMachineStatus:false,
  551. //选中的是那个车间
  552. selectedWorkshop:"南车间",
  553. tableData:[],
  554. isDisabled:true,
  555. form: {
  556. product:"",
  557. },
  558. previousMachineId: undefined,
  559. currentRowspan: 1,
  560. prevRow: {},
  561. tableData2: [],
  562. nanInsertDialogTableVisible:false,
  563. nanUpdateDialogTableVisible:false,
  564. beiInsertDialogTableVisible:false,
  565. beiUpdateDialogTableVisible:false,
  566. editingRowIndex: -1,
  567. lastEditLine:0,
  568. queryParams:{ productionLineDepartment:"加弹部",
  569. productionLineWorkshop:"南车间"},
  570. isEditLine:false,
  571. productsInfo:[],
  572. salesmanInfo:[],
  573. product:{},
  574. materiel:{},
  575. // 机台号
  576. machineId:"",
  577. macId:"",//机台id
  578. // 待机/上机/停产
  579. stateList0:[
  580. {"id":0,"name":"待机"},
  581. {"id":1,"name":"上机"},
  582. ],
  583. stateList1:[
  584. {"id":0,"name":"待机"},
  585. {"id":2,"name":"停机"},
  586. {"id":1,"name":"上机"},
  587. ],
  588. stateList2:[
  589. {"id":0,"name":"待机"},
  590. {"id":2,"name":"停机"},
  591. {"id":1,"name":"上机"},
  592. ],
  593. formData:{
  594. updateSelectedProductCategory:"",
  595. updateSelectedProductState:""
  596. },
  597. // 产品类别
  598. productTypeList:[{value:"A面",lable:"A面"},{value:"B面",lable:"B面"}],
  599. }
  600. },
  601. mounted() {
  602. // 得到排产计划信息
  603. this.getAmmunitionPlanInfo();
  604. },
  605. methods: {
  606. getProductChineseName(productId) {
  607. return this.productsInfo.find(product => product.id == productId).productName;
  608. },
  609. //删除计划
  610. deletePlan($index,row){
  611. console.log(row)
  612. //判断当前计划是否已经投产
  613. getJtIsTheOrderProductProduced({"id":row.id}).then(resp=>{
  614. if(resp.data.length>0){
  615. this.$message({message: '当前计划订单产品在生产中已经不能删除', type: 'warning'});
  616. return;//证明有在上级的产品--zhi能有一个上级产品
  617. }
  618. removeBombLoadingPlan(row.id).then(res=>{
  619. if(res.code==200){
  620. this.$message({
  621. message: '删除成功',
  622. type: 'success'
  623. });
  624. }else{
  625. this.$message({message:"删除失败",type: 'error'})
  626. }
  627. this.onSubmit();
  628. this.getAmmunitionPlanInfo();
  629. })
  630. });
  631. },
  632. //打开修改机台信息
  633. handleStopProductionLine(row){
  634. this.modifyMachineStatus=true;
  635. this.machineId=row.machineId;
  636. this.macId=row.macId;//机台id
  637. //查询当前机台A、面B面的状态
  638. whetherTheFeederIsShutDown(this.macId).then(res=>{
  639. this.modifyMachineStatusFrom.type=res.data;
  640. })
  641. },
  642. //确认修改产线信息
  643. confirmStopProductionLine(){
  644. // console.log(this.modifyMachineStatusFrom.type);
  645. if(this.modifyMachineStatusFrom.type.length==0){
  646. this.modifyMachineStatusFrom.type.push("3")
  647. }
  648. //更改状态
  649. updateLineStates(this.macId,this.modifyMachineStatusFrom.type.join(",")).then(res=>{
  650. if(res.code==200){
  651. this.$message({
  652. message: '修改状态成功',
  653. type: 'success'
  654. });
  655. }else{
  656. this.$message({message:"修改状态成功",type: 'error'})
  657. }
  658. this.modifyMachineStatus=false;
  659. this.getAmmunitionPlanInfo();
  660. })
  661. // //如果为空代表都不停机
  662. // if(this.modifyMachineStatusFrom.type.length<=0){
  663. // this.modifyMachineStatus=false;
  664. // //发送请求删除,A面-timestampRandomCode="停机" B-timestampRandomCode="停机"的数据、并把所有上机产品的状态改为上机
  665. // return;
  666. // }
  667. // // 包含1A停机---插入一条 timestampRandomCode=停机,状态为停机的数据
  668. // if (this.modifyMachineStatusFrom.type.includes("1")) {
  669. // //查询当前机台A、面B面的状态
  670. // whetherTheFeederIsShutDown(this.machineId).then(res=>{
  671. // //后台没有虚拟的假数据,就插入
  672. // if(!res.data.includes("1")){
  673. // console.log('数组中不包含数字 1');
  674. // //新增一条数据,
  675. // let aStopInfo= {
  676. // currentColorCode: '1',
  677. // //产品规格
  678. // currentSpecification: '1',
  679. // currentLotNumber: '1',
  680. // currentSpindleCount: '1',
  681. // number: '1',
  682. // productType:'A面',
  683. // startTime: '1',
  684. // plannedEndTime:'1',
  685. // planStatus:2,
  686. // productId:'1',
  687. // machineId:this.machineId,
  688. // salesmanId:'1',
  689. // timestampRandomCode:"停机",
  690. // }
  691. // let aStoptableList=[];
  692. // aStoptableList.push(aStopInfo)
  693. // //时间戳
  694. // let data={
  695. // //机台号
  696. // machineId: this.machineId,
  697. // //计划信息
  698. // detailsOfTheRefuelingPlans: aStoptableList
  699. // }
  700. // //添加计划信息
  701. // addMaterielInfo(data).then(response => {
  702. // if (response.code == 200) {
  703. // this.$message({
  704. // message: '停机成功',
  705. // type: 'success'
  706. // });
  707. // this.getAmmunitionPlanInfo();
  708. // //最后把弹窗关掉
  709. // this.nanInsertDialogTableVisible=false
  710. // //更改订单投产信息的批号,
  711. // } else {
  712. // this.$message({
  713. // message: '停机失败,请联系管理员',
  714. // type: 'error'
  715. // });
  716. // //最后把弹窗关掉
  717. // this.nanInsertDialogTableVisible=false
  718. // }
  719. // });
  720. // }
  721. // })
  722. // }
  723. // if(this.modifyMachineStatusFrom.type.includes("2")) {
  724. // whetherTheFeederIsShutDown(this.machineId).then(res=>{
  725. // if(!res.data.includes("2")) {
  726. // console.log('数组中不包含数字2');
  727. // //新增一条数据,
  728. // let aStopInfo= {
  729. // currentColorCode: '1',
  730. // //产品规格
  731. // currentSpecification: '1',
  732. // currentLotNumber: '1',
  733. // currentSpindleCount: '1',
  734. // number: '1',
  735. // productType:'B面',
  736. // startTime: '1',
  737. // plannedEndTime:'1',
  738. // planStatus:2,
  739. // productId:'1',
  740. // machineId:this.machineId,
  741. // salesmanId:'1',
  742. // timestampRandomCode:"停机",
  743. // }
  744. // let aStoptableList=[];
  745. // aStoptableList.push(aStopInfo)
  746. // //时间戳
  747. // let data={
  748. // //机台号
  749. // machineId: this.machineId,
  750. // //计划信息
  751. // detailsOfTheRefuelingPlans: aStoptableList
  752. // }
  753. // //添加计划信息
  754. // addMaterielInfo(data).then(response => {
  755. // if (response.code == 200) {
  756. // this.$message({
  757. // message: '停机成功',
  758. // type: 'success'
  759. // });
  760. // this.getAmmunitionPlanInfo();
  761. // //最后把弹窗关掉
  762. // this.nanInsertDialogTableVisible=false
  763. // //更改订单投产信息的批号,
  764. // } else {
  765. // this.$message({
  766. // message: '停机失败,请联系管理员',
  767. // type: 'error'
  768. // });
  769. // //最后把弹窗关掉
  770. // this.nanInsertDialogTableVisible=false
  771. // }
  772. // });
  773. // }
  774. // })
  775. // }
  776. },
  777. // 查询排产信息
  778. getAmmunitionPlanInfo() {
  779. ammunitionPlanInfo(this.queryParams).then((response) => {
  780. this.tableData = response.data
  781. });
  782. },
  783. // 合并单元格
  784. spanMethod2({ row, column, rowIndex, columnIndex }) {
  785. //第二列合并
  786. if (columnIndex === 1) {
  787. if(row.productType == null) {
  788. return;
  789. }
  790. const prevRow2 = this.tableData[rowIndex - 1]; // 上一行数据
  791. let nextRow2 = this.tableData[rowIndex + 1]; // 下一行数据
  792. // 当上一行的数据(machineId和productType)等于当前行数据时,当前行单元格隐藏
  793. if (
  794. prevRow2 &&
  795. prevRow2.machineId === row.machineId &&
  796. prevRow2.productType === row.productType
  797. ) {
  798. return { rowspan: 0, colspan: 0 };
  799. } else {
  800. // 反之,则循环判断若下一行数据(machineId和productType)等于当前行数据,则当前行开始进行合并单元格
  801. let countRowspan2 = 1; // 用于合并计数多少单元格
  802. while (
  803. nextRow2 &&
  804. nextRow2.machineId === row.machineId &&
  805. nextRow2.productType === row.productType
  806. ) {
  807. nextRow2 = this.tableData[++countRowspan2 + rowIndex];
  808. }
  809. if (countRowspan2 > 1) {
  810. return { rowspan: countRowspan2, colspan: 1 };
  811. }
  812. }
  813. }
  814. //待生产列表
  815. if (columnIndex === 9) {
  816. const prevRow2 = this.tableData[rowIndex - 1] //上一行数据
  817. let nextRow2 = this.tableData[rowIndex + 1] //下一行数据
  818. // 当上一行的数据等于当前行数据时,当前行单元格隐藏
  819. if(row.listOfPendingProduction==null||row.listOfPendingProduction==undefined|| row.listOfPendingProduction==""){
  820. return;
  821. }
  822. if (prevRow2 &&
  823. prevRow2.machineId === row.machineId &&
  824. prevRow2.productType === row.productType
  825. ) {
  826. return { rowspan: 0, colspan: 0 }
  827. } else {
  828. // 反之,则循环判断若下一行数据等于当前行数据,则当前行开始进行合并单元格
  829. let countRowspan2 = 1 //用于合并计数多少单元格
  830. while (nextRow2 &&
  831. nextRow2.listOfPendingProduction === row.listOfPendingProduction&&
  832. nextRow2.machineId === row.machineId &&
  833. nextRow2.productType === row.productType
  834. ) {
  835. nextRow2 = this.tableData[++countRowspan2 + rowIndex]
  836. }
  837. if (countRowspan2 > 1) {
  838. return { rowspan: countRowspan2, colspan: 1 }
  839. }
  840. }
  841. }
  842. //合并最后一列操作列
  843. const lastColumnIndex = this.$refs.tableRef.store.states.columns.length - 1; // 获取表格最后一列的索引
  844. if (columnIndex === lastColumnIndex && column.label === '操作') { // 判断是否为最后一列且标签为'操作'
  845. const machineIdColumnIndex = 0; // 机台号列的索引假定为0
  846. const currentMachineId = row.machineId;
  847. let countRowspan = 1;
  848. const prevRow = this.tableData[rowIndex - 1];
  849. if (prevRow && prevRow.machineId === currentMachineId) {
  850. return { rowspan: 0, colspan: 0 };
  851. } else {
  852. let nextRow = this.tableData[rowIndex + 1];
  853. while (
  854. nextRow &&
  855. nextRow.machineId === currentMachineId
  856. ) {
  857. nextRow = this.tableData[++countRowspan + rowIndex];
  858. }
  859. if (countRowspan > 1) {
  860. return { rowspan: countRowspan, colspan: 1 };
  861. }
  862. }
  863. }
  864. //第一列机台号合并
  865. if (columnIndex === 0) {
  866. //定义需要合并的列字段,有哪些列需要合并,就自定义添加字段即可
  867. const fields = ['machineId']
  868. // 当前行的数据
  869. const cellValue = row[column.property]
  870. let countRowspan = 1 //用于合并计数多少单元格
  871. // 判断只合并定义字段的列数据
  872. if (cellValue && fields.includes(column.property)) {
  873. const prevRow = this.tableData[rowIndex - 1] //上一行数据
  874. let nextRow = this.tableData[rowIndex + 1] //下一行数据
  875. // 当上一行的数据等于当前行数据时,当前行单元格隐藏
  876. if (prevRow && prevRow[column.property] === cellValue) {
  877. return { rowspan: 0, colspan: 0 }
  878. } else {
  879. // 反之,则循环判断若下一行数据等于当前行数据,则当前行开始进行合并单元格
  880. let countRowspan = 1 //用于合并计数多少单元格
  881. while (nextRow && nextRow[column.property] === cellValue) {
  882. nextRow = this.tableData[++countRowspan + rowIndex]
  883. }
  884. if (countRowspan > 1) {
  885. return { rowspan: countRowspan, colspan: 1 }
  886. }
  887. }
  888. }
  889. }
  890. },
  891. getProductsInfo() {
  892. getProductsInfo("JT-").then((response) => {
  893. this.productsInfo = response.data;
  894. this.productsInfo.forEach(item => {
  895. item.productName = item.productName+"—"+item.materieEncoding+item.materieColorNumber
  896. });
  897. })
  898. },
  899. // 下拉框数据改变查询色号批号信息
  900. selectedChangeDate(row,selectedProduct) {
  901. //选择的那个销售产品
  902. this.product = this.productsInfo.find(product => product.id === selectedProduct);
  903. this.form.product=selectedProduct;
  904. //通过母粒编码查询到对应的母粒信息
  905. let queryParams = {
  906. "materielCode": this.product.colourNumber
  907. }
  908. //得到对应的母粒信息
  909. getMaterielInfo(queryParams).then((response) => {
  910. if (response.data!=null) {
  911. this.materiel = response.data;
  912. //色号 母粒编码+色号
  913. row.currentColorCode = this.materiel.materieEncoding+"("+this.materiel.materieColorNumber+")";
  914. }
  915. });
  916. //isDisabled(有批号就用,没批号就自己输入)
  917. if(this.product.lotNumber!=undefined&&this.product.lotNumber!=""){
  918. row.currentLotNumber=this.product.lotNumber;
  919. this.isDisabled=true;
  920. }else {
  921. this.isDisabled=false;
  922. row.currentLotNumber="";
  923. }
  924. //产品规格
  925. row.currentSpecification= this.product.productSpecifications;
  926. //销售单编号(以前打算存的是业务员信息后来存的是销售单编号)
  927. row.salesmanId=this.product.saleOrderNo;
  928. //数量
  929. row.number=this.product.productNumber;
  930. // console.log(this.product,'ddddddddddddddd')
  931. },
  932. // 新增计划产品信息
  933. handleAddPlan(row) {
  934. //查询当前机台A、面B面的状态(这个不用改,因为这个是唯一的)
  935. whetherTheFeederIsShutDown(row.macId).then(res=>{
  936. this.modifyMachineStatusFrom.type=res.data;
  937. if(this.modifyMachineStatusFrom.type.includes("2")&&this.modifyMachineStatusFrom.type.includes("1")){
  938. this.$message({
  939. message: 'AB都已停机请更改机台状态',
  940. type: 'warning'
  941. });
  942. return;
  943. }else {
  944. if(this.modifyMachineStatusFrom.type.includes("1")){
  945. this.productTypeList=[]
  946. this.productTypeList.push({value:"B面",lable:"B面"})
  947. }
  948. if(this.modifyMachineStatusFrom.type.includes("2")){
  949. this.productTypeList=[]
  950. this.productTypeList.push({value:"A面",lable:"A面"})
  951. }
  952. if(this.modifyMachineStatusFrom.type.length<=0){
  953. this.productTypeList=[]
  954. this.productTypeList.push({value:"A面",lable:"A面"})
  955. this.productTypeList.push({value:"B面",lable:"B面"})
  956. }
  957. //否则就打开弹窗添加计划
  958. if(this.selectedWorkshop=="南车间"){
  959. this.nanInsertDialogTableVisible = true
  960. }else{
  961. this.beiInsertDialogTableVisible = true
  962. }
  963. //查询可以添加的产品信息
  964. this.getProductsInfo();
  965. //清空添加的数组对象
  966. this.tableData2=[]
  967. //先清空
  968. this.machineId=""
  969. //当前操作机台号
  970. this.machineId=row.machineId;
  971. this.macId=row.macId;
  972. }
  973. })
  974. },
  975. // tab栏点击切换
  976. tabClick(tab, event) {
  977. // console.log('当前点击的标签名称:', tab.name);
  978. this.selectedWorkshop = tab.name;
  979. // productionLineName getProductionLineNo productionLineDepartment productionLineWorkshop
  980. this.queryParams.productionLineWorkshop = tab.name;
  981. this.getAmmunitionPlanInfo();
  982. },
  983. // 删除行
  984. handleDelete(index, row) {
  985. // console.log(index,row)
  986. // this.tableData2[a];
  987. this.tableData2.splice(index, 1);
  988. // 把上一编辑行置回-1
  989. this.editingRowIndex = -1;
  990. },
  991. // 点击编辑行
  992. handleRowClick(row) {
  993. this.isEditLine = true;
  994. // alert(this.lastEditLine+"编辑行")
  995. //找到当前行的编辑索引
  996. var rowIndex = this.tableData2.indexOf(row);
  997. if (this.lastEditLine != 0 &&
  998. this.editingRowIndex !== rowIndex &&
  999. this.editingRowIndex !== -1 &&
  1000. !this.isRowFilled(this.tableData2[this.lastEditLine])) {
  1001. this.$message({
  1002. message: '请先完成上一条数据的填写',
  1003. type: 'warning'
  1004. });
  1005. return;
  1006. }
  1007. //编辑索引不等于当前编辑行索引
  1008. if (this.editingRowIndex !== rowIndex) {
  1009. // alert(this.editingRowIndex);
  1010. if (this.editingRowIndex !== -1) {
  1011. //把当前行变成不可编辑的
  1012. this.tableData2[this.editingRowIndex].isEditing = false;
  1013. }
  1014. //把当前行变成可编辑的
  1015. row.isEditing = true;
  1016. this.editingRowIndex = rowIndex;
  1017. }
  1018. },
  1019. // 光标失去焦点变成不可编辑
  1020. handleInputBlur(row) {
  1021. let rowIndex = this.tableData2.indexOf(row);
  1022. //编辑索引不等于当前编辑行索引
  1023. if (this.editingRowIndex !== rowIndex) {
  1024. if (this.isRowFilled(row)) {
  1025. row.isEditing = false;
  1026. //对于整个表格来说
  1027. this.isEditLine = false;
  1028. //当前编辑行置为-1
  1029. this.editingRowIndex = -1;
  1030. }
  1031. }
  1032. },
  1033. // 检查行是否填写完毕的示例方法
  1034. isRowFilled(row) {
  1035. return row.currentSpecification &&
  1036. row.currentSpindleCount &&
  1037. row.currentColorCode &&
  1038. row.productType &&
  1039. row.currentLotNumber &&
  1040. row.number &&
  1041. row.startTime &&
  1042. row.plannedEndTime;
  1043. },
  1044. // 新增一行标记为可编辑
  1045. addEditableRow() {
  1046. // 检查当前编辑行是否已填写完毕
  1047. if(this.tableData2.length!=0){
  1048. if (this.editingRowIndex !== -1 && !this.isRowFilled(this.tableData2[this.editingRowIndex])) {
  1049. this.$message({
  1050. message: '请先完成上一条数据的填写',
  1051. type: 'warning'
  1052. });
  1053. return;
  1054. }
  1055. //新增行之前先让以前的行不能编辑
  1056. this.tableData2.forEach(item => {
  1057. item.isEditing = false;
  1058. })
  1059. }
  1060. this.tableData2.push({
  1061. currentColorCode: '',
  1062. currentSpecification: '',
  1063. currentLotNumber: '',
  1064. currentSpindleCount: '',
  1065. number: '',
  1066. startTime: '',
  1067. plannedEndTime:'',
  1068. planStatus:0,
  1069. productId:'',
  1070. salesmanId:'',
  1071. isEditing: true // 标记为正在编辑状态
  1072. });
  1073. this.editingRowIndex = this.tableData2.length - 1; // 更新当前编辑的行索引
  1074. this.lastEditLine = this.tableData2.length - 1
  1075. },
  1076. // 添加计划
  1077. addPlanInfo(){
  1078. if(this.tableData2.length>0){
  1079. var flag=true;
  1080. this.tableData2.forEach(item=>{
  1081. if(!this.isRowFilled(item)){
  1082. this.$message({
  1083. message: '请先完善表格数据',
  1084. type: 'warning'
  1085. });
  1086. flag=false
  1087. }
  1088. })
  1089. if(flag){
  1090. const datatime=Date.now()+this.machineId;
  1091. //处理表格数据
  1092. this.tableData2.forEach(item=>{
  1093. item.timestampRandomCode=datatime;
  1094. item.machineId=this.machineId;
  1095. })
  1096. //时间戳
  1097. let data={
  1098. //机台号
  1099. machineId: this.machineId,
  1100. macId:this.macId,
  1101. timestampRandomCode:datatime,
  1102. //计划信息
  1103. detailsOfTheRefuelingPlans: this.tableData2
  1104. }
  1105. //添加计划信息
  1106. addMaterielInfo(data).then(response => {
  1107. if (response.code == 200) {
  1108. this.$message({
  1109. message: '添加成功',
  1110. type: 'success'
  1111. });
  1112. this.getAmmunitionPlanInfo();
  1113. //最后把弹窗关掉
  1114. this.nanInsertDialogTableVisible = false
  1115. this.beiInsertDialogTableVisible = false
  1116. //更改订单投产信息的批号,
  1117. } else {
  1118. this.$message({
  1119. message: '添加失败',
  1120. type: 'error'
  1121. });
  1122. this.nanInsertDialogTableVisible = false
  1123. this.beiInsertDialogTableVisible = false
  1124. //最后把弹窗关掉
  1125. }
  1126. });
  1127. }
  1128. }else {
  1129. this.$message({
  1130. message: '请先添加表格数据',
  1131. type: 'warning'
  1132. });
  1133. return;
  1134. }
  1135. },
  1136. // 修改产品计划
  1137. handleEditPlan(row) {
  1138. //已经在待机列表了,isNull过滤掉了
  1139. getProductsAll(row.macId).then((response) => {
  1140. this.productsInfo = response.data;
  1141. this.productsInfo.forEach(item => {
  1142. item.productName = item.productName+"—"+item.materieEncoding+item.materieColorNumber
  1143. });
  1144. this.tableData2=[];
  1145. //弹窗
  1146. if(this.selectedWorkshop=="南车间"){
  1147. this.nanUpdateDialogTableVisible = true
  1148. }else{
  1149. this.beiUpdateDialogTableVisible = true
  1150. }
  1151. //先清空--当前操作机台号
  1152. this.machineId=""
  1153. this.machineId=row.machineId;
  1154. this.macId=row.macId;
  1155. //查询当前机台下的计划信息
  1156. getAllPlanListByMachineId(this.macId).then((response) => {
  1157. //得到生产中,停产的,待产的
  1158. response.data.forEach(item => {
  1159. item.isEditing=false;
  1160. item.planStatus=parseInt(item.planStatus);
  1161. item.productId=parseInt(item.productId)
  1162. })
  1163. this.tableData2=response.data;
  1164. // console.log( this.tableData2)
  1165. })
  1166. })
  1167. },
  1168. //重置按钮
  1169. reset(){
  1170. this.tableData2=[];
  1171. //弹窗
  1172. if(this.selectedWorkshop=="南车间"){
  1173. this.nanUpdateDialogTableVisible = true
  1174. }else{
  1175. this.beiUpdateDialogTableVisible = true
  1176. }
  1177. console.log(this.machineId,"dddd")
  1178. getAllPlanListByMachineId(this.machineId).then((response) => {
  1179. //得到生产中,停产的,待产的
  1180. response.data.forEach(item => {
  1181. item.isEditing=false;
  1182. item.planStatus=parseInt(item.planStatus);
  1183. item.productId=parseInt(item.productId)
  1184. })
  1185. this.tableData2=response.data;
  1186. // console.log( this.tableData2)
  1187. // 在数据加载完成后,手动触发每个行的第一个下拉框的 change 事件
  1188. this.$nextTick(() => {
  1189. // 获取第一个业务员选择框(假设表格只有一行)
  1190. for (let i = 0; i < this.tableData2.length; i++) {
  1191. const firstSalesmanSelect = this.$refs['salesmanSelect'+i];
  1192. // 触发 change 事件
  1193. if (firstSalesmanSelect) {
  1194. firstSalesmanSelect.$emit('change', {
  1195. target: {value: "ddd"},
  1196. });
  1197. }
  1198. }
  1199. });
  1200. })
  1201. },
  1202. //弹窗里边的点击查询
  1203. onSubmit(){
  1204. this.formData.macId=this.macId;
  1205. getAllPlanListByProductTypeAndStatus(this.formData).then(response => {
  1206. //得到生产中,停产的,待产的
  1207. response.data.forEach(item => {
  1208. item.isEditing=false;
  1209. item.planStatus=parseInt(item.planStatus);
  1210. })
  1211. this.tableData2=response.data;
  1212. });
  1213. },
  1214. //更新状态
  1215. updateStatus(ind, row){
  1216. if(!this.isRowFilled(row)){
  1217. this.$message({message: '请完善当前行数据', type: 'warning'});
  1218. return;
  1219. }
  1220. //判断当前计划是否已经投产
  1221. getJtIsTheOrderProductProduced({"id":row.id}).then(resp=>{
  1222. if(resp.data.length>0) {
  1223. this.$message({message: '当前计划订单产品在生产中已经不能修改', type: 'warning'});
  1224. return;//证明有在上级的产品--zhi能有一个上级产品
  1225. }
  1226. //不是投产中就可以更新了.
  1227. updatePlanOne(row).then(response=>{
  1228. if (response.code == 200) {
  1229. this.$message({
  1230. message: '修改成功',
  1231. type: 'success'
  1232. });
  1233. this.getAmmunitionPlanInfo();
  1234. //最后把弹窗关掉
  1235. this.nanInsertDialogTableVisible=false
  1236. this.beiUpdateDialogTableVisible=false
  1237. } else {
  1238. this.$message({
  1239. message: '修改失败',
  1240. type: 'error'
  1241. });
  1242. //最后把弹窗关掉
  1243. this.nanInsertDialogTableVisible=false
  1244. this.beiUpdateDialogTableVisible=false
  1245. }
  1246. })
  1247. })
  1248. }
  1249. }
  1250. }
  1251. </script>
  1252. <style scoped>
  1253. .el-tabs--border-card >>> .el-tabs__content {
  1254. padding: 0 !important;
  1255. }
  1256. .el-table__body-wrapper {
  1257. cursor: grab;
  1258. }
  1259. .el-table__body-wrapper.grabbing {
  1260. cursor: grabbing;
  1261. }
  1262. .container >>> .el-table .cell {
  1263. white-space: pre-line;
  1264. }
  1265. </style>