allocation.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <section>
  3. <!--工具条-->
  4. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  5. <el-form :inline="true" :model="filters">
  6. <el-col :span="3">
  7. <el-form-item>
  8. <el-select v-model="filters.value" placeholder="按公司筛选">
  9. <el-option label="编号" value="0"></el-option>
  10. <el-option label="名称" value="1"></el-option>
  11. </el-select>
  12. </el-form-item>
  13. </el-col>
  14. <el-form-item>
  15. <el-input v-model="filters.name" placeholder="请输入关键字进行搜索"></el-input>
  16. </el-form-item>
  17. <el-form-item>
  18. <el-button type="primary">查询</el-button>
  19. </el-form-item>
  20. <el-form-item style="float: right;">
  21. <el-button type="primary" @click="showAllocation">分配云模</el-button>
  22. </el-form-item>
  23. </el-form>
  24. </el-col>
  25. <!--列表-->
  26. <el-table :data="allocations" :height="tableHeight" highlight-current-row v-loading="listLoading" style="width: 100%;">
  27. <el-table-column type="index" width="60"></el-table-column>
  28. <el-table-column prop="id" label="云模设备号" width="120" sortable></el-table-column>
  29. <el-table-column prop="power" label="电量" width="80" sortable></el-table-column>
  30. <el-table-column prop="useLife" label="倒计时" width="100" sortable></el-table-column>
  31. <el-table-column prop="equipmentName" label="模具名称" width="100" sortable></el-table-column>
  32. <el-table-column prop="equipmentNo" label="模具编号" width="120" sortable></el-table-column>
  33. <el-table-column prop="belongCompanyId" label="资产方" width="120" sortable></el-table-column>
  34. <el-table-column prop="state" label="模具状态" width="100" sortable>
  35. <template slot-scope="scope">
  36. <span v-if="scope.row.state == false">未启用</span>
  37. <span v-else>已启用</span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="操作" width="220" sortable>
  41. <template slot-scope="scope">
  42. <el-button
  43. size="small"
  44. type="primary"
  45. @click="enable(scope.$index)"
  46. :disabled="scope.row.state == true"
  47. >启用</el-button>
  48. <el-button size="small">修改</el-button>
  49. <el-button type="danger" size="small">删除</el-button>
  50. </template>
  51. </el-table-column>
  52. </el-table>
  53. <!--工具条-->
  54. <el-col :span="24" class="toolbar">
  55. <el-pagination
  56. @size-change="handleSizeChange"
  57. @current-change="handleCurrentChange"
  58. :page-sizes="[20 , 50 , 80 , 100]"
  59. :page-size="20"
  60. layout="total, sizes, prev, pager, next"
  61. :total="total"
  62. style="float:right;"
  63. ></el-pagination>
  64. </el-col>
  65. <!--新增界面-->
  66. <el-dialog
  67. title="新建模具"
  68. v-if="addFormVisible"
  69. :visible.sync="addFormVisible"
  70. :close-on-click-modal="false"
  71. customClass="customWidth"
  72. >
  73. <el-form
  74. :model="newAllocation"
  75. label-width="100px"
  76. :rules="formRules"
  77. ref="newAllocation"
  78. :inline="true"
  79. class="demo-form-inline"
  80. >
  81. <el-form-item label="设备号" prop="typeNumber">
  82. <el-input v-model="newAllocation.equipmentNo" autocomplete="off" placeholder="请填写"></el-input>
  83. </el-form-item>
  84. <el-form-item label="所属公司" prop="name">
  85. <el-input v-model="newAllocation.belongCompanyId" autocomplete="off" placeholder="请填写"></el-input>
  86. </el-form-item>
  87. </el-form>
  88. <div slot="footer" class="dialog-footer">
  89. <el-button @click.native="addFormVisible = false">取消</el-button>
  90. <el-button type="primary" @click="addMould">提交</el-button>
  91. </div>
  92. </el-dialog>
  93. <!--修改界面-->
  94. <el-dialog
  95. title="修改模具"
  96. v-if="editFormVisible"
  97. :visible.sync="editFormVisible"
  98. :close-on-click-modal="false"
  99. customClass="customWidth"
  100. >
  101. <el-form
  102. :model="newAllocation"
  103. label-width="100px"
  104. :rules="formRules"
  105. ref="newAllocation"
  106. :inline="true"
  107. class="demo-form-inline"
  108. >
  109. <el-form-item label="设备号" prop="typeNumber">
  110. <el-input v-model="newAllocation.equipmentNo" autocomplete="off" placeholder="请填写"></el-input>
  111. </el-form-item>
  112. <el-form-item label="所属公司" prop="name">
  113. <el-input v-model="newAllocation.belongCompanyId" autocomplete="off" placeholder="请填写"></el-input>
  114. </el-form-item>
  115. </el-form>
  116. <div slot="footer" class="dialog-footer">
  117. <el-button @click.native="editFormVisible = false">取消</el-button>
  118. <!-- 这里少了几个属性别忘了加上了 -->
  119. <el-button type="primary">提交</el-button>
  120. </div>
  121. </el-dialog>
  122. </section>
  123. </template>
  124. <script>
  125. import util from "../../common/js/util";
  126. export default {
  127. data() {
  128. return {
  129. allocations: [
  130. //临时数据
  131. {
  132. id: "1234567",
  133. power: "N/A",
  134. useLife: "400天",
  135. equipmentName: "墨盒",
  136. equipmentNo: "MUJU123456",
  137. belongCompanyId: "南京火石闪信",
  138. state: true
  139. },
  140. {
  141. id: "7891011",
  142. power: "N/A",
  143. useLife: "100天",
  144. equipmentName: "墨盒2",
  145. equipmentNo: "MUJU654321",
  146. belongCompanyId: "南京火石闪信",
  147. state: false
  148. }
  149. ],
  150. /**
  151. * 添加/修改模具设备
  152. * 添加参数:equipmentName 设备名称,useLife 使用年限, equipmentNo 设备编号 ,
  153. * belongCompanyId 所属公司id ,equipmentName 设备名称
  154. * 修改时需多传的参数 id 设备id
  155. */
  156. newAllocation: {
  157. equipmentNo: "", //设备编号
  158. // power: "",
  159. useLife: "", //使用年限
  160. equipmentName: "", //设备名称
  161. id: "", //设备id
  162. belongCompanyId: "" //所属公司ID
  163. },
  164. filters: {
  165. name: "",
  166. value: ""
  167. },
  168. formRules: {},
  169. listLoading: false,
  170. total: 0,
  171. tableHeight: 0,
  172. addFormVisible: false,
  173. editFormVisible: false
  174. };
  175. },
  176. methods: {
  177. //分页
  178. handleCurrentChange(val) {
  179. this.page = val;
  180. // this.getMoulds();
  181. },
  182. handleSizeChange(val) {
  183. this.size = val;
  184. // this.getMoulds();
  185. },
  186. //添加界面
  187. showAllocation() {
  188. this.addFormVisible = true;
  189. this.newAllocation = {
  190. id: "", //设备编号
  191. useLife: "", //使用年限
  192. equipmentName: "", //设备名称
  193. equipmentNo: "", //设备id
  194. belongCompanyId: "" //所属公司ID
  195. };
  196. },
  197. //修改界面
  198. showEdit() {
  199. this.editFormVisible = true;
  200. this.newAllocation = {
  201. id: "", //设备编号
  202. useLife: "", //使用年限
  203. equipmentName: "", //设备名称
  204. equipmentNo: "", //设备id
  205. belongCompanyId: "" //所属公司ID
  206. };
  207. },
  208. //添加模具
  209. addMould(){
  210. //添加模具调用
  211. this.$refs.addForm.validate(valid => {
  212. if (valid) {
  213. this.editLoading = true;
  214. this.http.post(
  215. this.port.base.editMould,
  216. {
  217. id: this.newAllocation.id,
  218. belongCompanyId: this.newAllocation,belongCompanyId
  219. },
  220. res => {
  221. this.editLoading = false;
  222. this.editFormVisible = false;
  223. if (res.code == "ok") {
  224. this.$message({
  225. message: "添加成功",
  226. type: "success"
  227. });
  228. this.getRoles();
  229. } else {
  230. this.$message({
  231. message: res.msg,
  232. type: "error"
  233. });
  234. }
  235. },
  236. error => {
  237. this.editLoading = false;
  238. this.editFormVisible = false;
  239. this.$message({
  240. message: error,
  241. type: "error"
  242. });
  243. }
  244. );
  245. }
  246. });
  247. },
  248. //启用设备
  249. enable(index) {
  250. this.allocations[index].state = true;
  251. //启用设备调用
  252. this.http.post(
  253. this.port.base.enableMould,
  254. {
  255. //数是瞎写的
  256. id: 1,
  257. isUse: 1
  258. },
  259. res => {
  260. if (res.code == "ok") {
  261. this.$message({
  262. message: "修改成功",
  263. type: "success"
  264. });
  265. this.getRoles();
  266. } else {
  267. this.$message({
  268. message: res.msg,
  269. type: "error"
  270. });
  271. }
  272. },
  273. error => {
  274. this.$message({
  275. message: error,
  276. type: "error"
  277. });
  278. }
  279. );
  280. }
  281. },
  282. created() {
  283. let height = window.innerHeight;
  284. this.tableHeight = height - 210;
  285. },
  286. mounted() {}
  287. };
  288. </script>
  289. <style scoped>
  290. </style>