moldList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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.projectId" clearable placeholder="请选择项目">
  9. <el-option v-for="item in projects" :key="item.id" :label="item.projectName" :value="item.id"></el-option>
  10. </el-select>
  11. </el-form-item>
  12. </el-col>
  13. <el-col :span="3">
  14. <el-form-item>
  15. <el-select v-model="filters.searchType" placeholder="请选择查询条件">
  16. <el-option label="编号" value="0"></el-option>
  17. <el-option label="名称" value="1"></el-option>
  18. </el-select>
  19. </el-form-item>
  20. </el-col>
  21. <el-form-item>
  22. <el-input v-model="filters.keyName" placeholder="请输入编号或名称进行搜索"></el-input>
  23. </el-form-item>
  24. <el-form-item>
  25. <el-button type="primary" @click="getMoldList">查询</el-button>
  26. </el-form-item>
  27. <el-form-item style="float: right" v-if="user.parentId == 1">
  28. <el-button type="primary" @click="showAdd">新建</el-button>
  29. </el-form-item>
  30. </el-form>
  31. </el-col>
  32. <!--列表-->
  33. <el-table :data="molds" :height="tableHeight" highlight-current-row v-loading="listLoading" style="width: 100%;">
  34. <el-table-column type="index" width="40"></el-table-column>
  35. <el-table-column prop="modelName" label="模具名称" width="140" sortable>
  36. <template slot-scope="scope">
  37. <el-link :underline="false" type="primary" @click="toDetail(scope.row)">{{scope.row.modelName}}</el-link>
  38. </template>
  39. </el-table-column>
  40. <el-table-column prop="modelNo" label="模具编号" width="120" sortable></el-table-column>
  41. <el-table-column prop="equipmentNo" label="云模盒编号" width="120" sortable></el-table-column>
  42. <el-table-column prop="hillNumber" label="电量" align="center" width="100" sortable></el-table-column>
  43. <el-table-column prop="diffTime" label="倒计时" align="center" width="100" sortable></el-table-column>
  44. <el-table-column prop="projectName" label="所属项目" width="140" sortable></el-table-column>
  45. <el-table-column prop="companyName" label="所属资产方" width="300" sortable></el-table-column>
  46. <el-table-column prop="produceCompany" label="所属生产方" width="200" sortable></el-table-column>
  47. <el-table-column prop="initialModulus" label="初始模次" width="100" align="center" sortable></el-table-column>
  48. <el-table-column prop="settingLife" label="模次寿命" width="100" align="center" sortable></el-table-column>
  49. <el-table-column prop="initial" label="穴数" width="100" align="center" sortable></el-table-column>
  50. <el-table-column prop="rfid" label="对应RFID码" width="120" align="center" sortable></el-table-column>
  51. <el-table-column label="状态" width="100" align="center" sortable>
  52. <template slot-scope="scope">
  53. <span v-if="scope.row.state == 1" style="color:#00CD66;">运行</span>
  54. <span v-else style="color:#999999;">静止</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="操作" width="150" align="center" fixed="right" sortable v-if="user.parentId == 1">
  58. <template slot-scope="scope">
  59. <el-button size="small" type="danger" @click="handleDel(scope.row)">删除</el-button>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. <!--工具条-->
  64. <el-col :span="24" class="toolbar">
  65. <el-pagination
  66. @size-change="handleSizeChange"
  67. @current-change="handleCurrentChange"
  68. :page-sizes="[20 , 50 , 80 , 100]"
  69. :page-size="20"
  70. layout="total, sizes, prev, pager, next"
  71. :total="total"
  72. style="float:right;"
  73. ></el-pagination>
  74. </el-col>
  75. <!--新增界面-->
  76. <el-dialog title="新建模具" v-if="addFormVisible" :visible.sync="addFormVisible" :close-on-click-modal="false" customClass="customWidth">
  77. <el-form :model="addForm" label-width="100px" :rules="formRules" ref="addForm" :inline="true" class="demo-form-inline">
  78. <el-form-item label="模具名称" prop="modelName">
  79. <el-input v-model="addForm.modelName" autocomplete="off" placeholder="请输入模具名称"></el-input>
  80. </el-form-item>
  81. <el-form-item label="模具编号" prop="modelNo">
  82. <el-input v-model="addForm.modelNo" autocomplete="off" placeholder="请输入模具编号"></el-input>
  83. </el-form-item>
  84. <el-form-item label="云模盒编号" prop="equipmentId">
  85. <el-select v-model="addForm.equipmentId" clearable filterable placeholder="请选择云模盒编号" style="width:202px">
  86. <el-option v-for="item in boxes" :key="item.id" :label="item.equipmentNo" :value="item.id"></el-option>
  87. </el-select>
  88. </el-form-item>
  89. </el-form>
  90. <div slot="footer" class="dialog-footer">
  91. <el-button @click.native="addFormVisible = false">取消</el-button>
  92. <el-button type="primary" @click.native="addSubmit" :loading="addLoading">提交</el-button>
  93. </div>
  94. </el-dialog>
  95. </section>
  96. </template>
  97. <script>
  98. import util from "../../common/js/util";
  99. export default {
  100. data() {
  101. return {
  102. user: JSON.parse(sessionStorage.getItem("user")),
  103. molds: [],
  104. filters: {
  105. keyName: "",
  106. searchType: "编号",
  107. projectId: ""
  108. },
  109. team: [{label:'资产方',value:0},{label:'生产方',value:1}],
  110. formRules: {
  111. modelNo: [
  112. { required: true, message: "请输入模具编号", trigger: "blur" }
  113. ],
  114. modelName: [
  115. { required: true, message: "请输入模具名称", trigger: "blur" }
  116. ],
  117. equipmentId: [
  118. {
  119. required: true,
  120. message: "请选择云模盒编号",
  121. trigger: ["blur", "change"]
  122. }
  123. ]
  124. },
  125. listLoading: false,
  126. total: 0,
  127. tableHeight: 0,
  128. boxes: [],
  129. projects: [],
  130. addLoading: false,
  131. addFormVisible: false,
  132. addForm: {
  133. modelNo: "",
  134. modelName: "",
  135. equipmentId: ""
  136. }
  137. };
  138. },
  139. methods: {
  140. getMsg() {
  141. this.http.post( this.port.base.moulds, {
  142. belongCompanyId: this.user.companyId
  143. },
  144. res => {
  145. if (res.code == "ok") {
  146. this.boxes = res.data;
  147. } else {
  148. this.$message({
  149. message: res.msg,
  150. type: "error"
  151. });
  152. }
  153. },
  154. error => {
  155. this.listLoading = false;
  156. this.$message({
  157. message: error,
  158. type: "error"
  159. });
  160. });
  161. this.http.post( this.port.project.projects, {},
  162. res => {
  163. if (res.code == "ok") {
  164. this.projects = res.data;
  165. } else {
  166. this.$message({
  167. message: res.msg,
  168. type: "error"
  169. });
  170. }
  171. },
  172. error => {
  173. this.listLoading = false;
  174. this.$message({
  175. message: error,
  176. type: "error"
  177. });
  178. });
  179. },
  180. //分页
  181. handleCurrentChange(val) {
  182. this.page = val;
  183. this.getMoldList();
  184. },
  185. handleSizeChange(val) {
  186. this.size = val;
  187. this.getMoldList();
  188. },
  189. //获取模具列表
  190. getMoldList() {
  191. this.listLoading = true;
  192. this.http.post( this.port.mold.molds, {
  193. keyName: this.filters.keyName,
  194. pageNum: this.page,
  195. pageSize: this.size,
  196. projectId: this.filters.projectId == "" ? -1 : this.filters.projectId,
  197. searchType: this.filters.searchType == "编号"? 0:1
  198. },
  199. res => {
  200. this.listLoading = false;
  201. if (res.code == "ok") {
  202. var list = res.data.list
  203. for(var i in list){
  204. if(list[i].endTime == null){
  205. list[i].diffTime = "";
  206. } else {
  207. list[i].diffTime = util.formatDate.dateDiff(
  208. util.formatDate.format(new Date(list[i].endTime), 'yyyy-MM-dd'),
  209. util.formatDate.format(new Date(new Date()), 'yyyy-MM-dd')
  210. );
  211. }
  212. }
  213. this.molds = list;
  214. this.total = res.data.total;
  215. } else {
  216. this.$message({
  217. message: res.msg,
  218. type: "error"
  219. });
  220. }
  221. },
  222. error => {
  223. this.listLoading = false;
  224. this.$message({
  225. message: error,
  226. type: "error"
  227. });
  228. });
  229. },
  230. //详情
  231. toDetail(row) {
  232. this.$router.push("/moldList/" + row.id);
  233. },
  234. //删除
  235. handleDel: function (row) {
  236. this.$confirm('确认删除该模具吗?', '提示', {
  237. type: 'warning'
  238. }).then(() => {
  239. this.http.post(this.port.mold.delMold, {
  240. id: row.id
  241. }, res => {
  242. if (res.code == "ok") {
  243. this.$message({
  244. message: '删除成功',
  245. type: 'success'
  246. });
  247. this.getUsers();
  248. } else {
  249. this.$message({
  250. message: res.msg,
  251. type: 'error'
  252. });
  253. }
  254. }, error => {
  255. this.$message({
  256. message: error,
  257. type: 'error'
  258. });
  259. })
  260. });
  261. },
  262. //添加界面
  263. showAdd() {
  264. this.addFormVisible = true;
  265. this.addForm = {
  266. modelNo: "",
  267. modelName: "",
  268. equipmentId: ""
  269. };
  270. },
  271. addSubmit() {
  272. this.$refs.addForm.validate(valid => {
  273. if (valid) {
  274. this.addLoading = true;
  275. this.http.post(
  276. this.port.mold.addMold,
  277. this.addForm,
  278. res => {
  279. this.addLoading = false;
  280. if (res.code == "ok") {
  281. this.addFormVisible = false;
  282. this.$message({
  283. message: "创建成功",
  284. type: "success"
  285. });
  286. this.getMoldList();
  287. } else {
  288. this.$message({
  289. message: res.msg,
  290. type: "error"
  291. });
  292. }
  293. },
  294. error => {
  295. this.addLoading = false;
  296. this.addFormVisible = false;
  297. this.$message({
  298. message: error,
  299. type: "error"
  300. });
  301. });
  302. }
  303. });
  304. }
  305. },
  306. created() {
  307. let height = window.innerHeight;
  308. this.tableHeight = height - 210;
  309. const that = this;
  310. window.onresize = function temp() {
  311. that.tableHeight = window.innerHeight - 210;
  312. };
  313. },
  314. mounted() {
  315. this.getMsg();
  316. this.getMoldList();
  317. }
  318. };
  319. </script>
  320. <style scoped>
  321. </style>