index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <div class="container">
  3. <div class="header-box">
  4. <p> 剩料计划</p>
  5. <el-button type="primary" plain class="add-btn" @click="dialogVisible = true">新 增</el-button>
  6. </div>
  7. <div class="table">
  8. <el-table
  9. element-loading-text="给我一点时间"
  10. :data="tableData"
  11. border
  12. fit
  13. highlight-current-row
  14. style="width: 100%;"
  15. class="elTable table-fixed"
  16. >
  17. <el-table-column
  18. label="序号"
  19. width="60"
  20. type="index"
  21. >
  22. </el-table-column>
  23. <el-table-column
  24. label="替代方案"
  25. prop="name"
  26. width="180">
  27. </el-table-column>
  28. <el-table-column label="操作">
  29. <template slot-scope="scope">
  30. <el-button
  31. size="mini"
  32. class="miniSuccess"
  33. icon="el-icon-edit-outline"
  34. @click="handleEdit(scope.$index, scope.row)"></el-button>
  35. <el-button
  36. size="mini"
  37. type="danger"
  38. icon="el-icon-delete"
  39. @click="handleDelete(scope.$index, scope.row)"></el-button>
  40. </template>
  41. </el-table-column>
  42. </el-table>
  43. <!-- -->
  44. <el-pagination
  45. class="page"
  46. @size-change="handleSizeChange"
  47. @current-change="handleCurrentChange"
  48. :current-page.sync="currentPage1"
  49. :page-size="100"
  50. layout="total, prev, pager, next"
  51. :total="1000">
  52. </el-pagination>
  53. </div>
  54. <!-- 新增删除提示 -->
  55. <el-dialog
  56. title="剩料新增"
  57. :visible.sync="dialogVisible"
  58. width="30%"
  59. >
  60. <div>
  61. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  62. <el-form-item label="替代方案" prop="name">
  63. <el-select v-model="ruleForm.name" placeholder="请选择替代方案">
  64. <el-option label="日料" value="1"></el-option>
  65. <el-option label="豆bo" value="2"></el-option>
  66. </el-select>
  67. </el-form-item>
  68. </el-form>
  69. </div>
  70. <span slot="footer" class="dialog-footer">
  71. <el-button class="add-btn" @click="dialogVisible = false">取 消</el-button>
  72. <el-button class="add-btn" type="primary" @click="dialogVisible = false">确 定</el-button>
  73. </span>
  74. </el-dialog>
  75. </div>
  76. </template>
  77. <script>
  78. import {
  79. GetDataByName,
  80. GetDataByNames
  81. } from '@/api/common'
  82. import Cookies from 'js-cookie'
  83. import {
  84. MessageBox
  85. } from 'element-ui'
  86. export default {
  87. name: 'LeftoverManagement',
  88. data() {
  89. return {
  90. tableData: [{
  91. id:1,
  92. num: '1',
  93. name: '日粮',
  94. }, {
  95. id:2,
  96. num: '2',
  97. name: '豆泊',
  98. }, {
  99. id:3,
  100. num: '3',
  101. name: '日粮',
  102. }],
  103. currentPage1: 1,
  104. dialogVisible:false,
  105. //
  106. ruleForm: {
  107. name: '',
  108. },
  109. rules:{
  110. name: [
  111. { required: true, message: '请选择替代方案', trigger: 'change' }
  112. ]
  113. }
  114. }
  115. },
  116. created() {},
  117. methods: {
  118. handleEdit(index, row) {
  119. console.log(index, row);
  120. // 获取当前数据,点击编辑
  121. this.ruleForm = row;
  122. this.dialogVisible = true;
  123. },
  124. handleDelete(index, row) {
  125. console.log(index, row);
  126. this.$confirm('确定删除当前剩料配置吗?', '提示', {
  127. confirmButtonText: '确定',
  128. confirmButtonText: this.$t('common.cancel'),
  129. type: 'warning'
  130. }).then(() => {
  131. this.$message({
  132. type: 'success',
  133. message: '删除成功!'
  134. });
  135. }).catch(() => {
  136. this.$message({
  137. type: 'info',
  138. message: this.$t('common.cancelMsg')
  139. });
  140. })
  141. },
  142. //
  143. handleSizeChange(val) {
  144. console.log(`每页 ${val} 条`);
  145. },
  146. handleCurrentChange(val) {
  147. console.log(`当前页: ${val}`);
  148. }
  149. },
  150. }
  151. </script>
  152. <style lang="scss" scoped>
  153. .header-box{
  154. display: flex;
  155. justify-content: space-between;
  156. }
  157. .container{
  158. padding: 15px;
  159. min-height:600px;
  160. margin-left:10px;
  161. .add-btn{
  162. width:90px;
  163. height:40px;
  164. }
  165. .page{
  166. margin-top:20px;
  167. }
  168. }
  169. </style>