fangsi.vue 29 KB

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