Index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <div class="formContaner" style="height:200px;">
  3. <el-form ref="form" :model="rowData" :rules="rules" label-position="right" label-width="150px">
  4. <el-form-item :label='$t("runCenter.form.areaName")+":"' v-model="rowData.name" >{{rowData.name}}</el-form-item>
  5. <el-form-item :label='$t("runCenter.form.setModel")+":"' >
  6. <el-select style="width:300px;" :placeholder='$t("common.pleaseSelect")' v-model="rowData.runMode" @change="changeMode" >
  7. <el-option :key="value" :label="key" :value="value" v-for="(key, value) in this.dicts.RUN_MODE" />
  8. </el-select>
  9. </el-form-item>
  10. </el-form>
  11. <div slot="footer" class="dialog-footer">
  12. <el-button type="primary" icon="el-icon-check" :disabled="confirmDisabled" @click="submitForm">{{ $t('runCenter.buttons.ok') }}</el-button>
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. // 【区域管理】-API
  18. import areaMgrApi from "@/api/resourceProductMgr/areaMgr"
  19. import orderMgrApi from "@/api/runManageCenter/orderMgr"
  20. // 共通的【查询方法】
  21. import { initDicts, initQueryParams } from '@/utils/commons'
  22. // 共通【工具方法】(字典分解)
  23. import { convertEnum } from '@/utils/utils'
  24. export default {
  25. name: "SetCurrentLine",
  26. components: {},
  27. props: {
  28. rowData: Object
  29. },
  30. data () {
  31. return {
  32. dicts: {
  33. RUN_MODE: {} //运行模式
  34. },
  35. confirmDisabled: false,
  36. bool: true,
  37. orderCount: 0,
  38. tenant: this.initTenant(),
  39. rules: {
  40. runMode: [
  41. { required: true, message: this.$t("rules.require"), trigger: 'change' }
  42. ]
  43. }
  44. }
  45. },
  46. // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
  47. created() {
  48. // 加载【字典】
  49. initDicts(['RUN_MODE'], this.dicts)
  50. //console.log(this.tenant)
  51. this.tenant = this.rowData
  52. this.checkCount()
  53. },
  54. computed: {
  55. currentUser () {
  56. return this.$store.state.account.user
  57. },
  58. runModelList() {
  59. return convertEnum(this.dicts.RUN_MODE)
  60. }
  61. },
  62. mounted () {
  63. },
  64. methods: {
  65. initTenant () {
  66. return {
  67. id: '',
  68. runMode: '',
  69. }
  70. },
  71. reset () {
  72. // 先清除校验,再清除表单,不然有奇怪的bug
  73. this.$refs.form.clearValidate()
  74. this.$refs.form.resetFields()
  75. this.tenant = this.initTenant()
  76. },
  77. changeMode(val) {
  78. this.bool = true
  79. let runMode = this.rowData.runMode
  80. if ( runMode === "1" || runMode === "3"){
  81. //弹框确认
  82. this.$confirm('确认要切换产线模式吗?', this.$t("common.tips"), {
  83. confirmButtonText: this.$t("common.confirm"),
  84. cancelButtonText: this.$t("common.cancel"),
  85. type: "warning"
  86. }).then(() => {
  87. }).catch(() => {
  88. this.$emit("close")
  89. });
  90. }
  91. else {
  92. this.$message({
  93. message: "请确保手动操作在系统已登记",
  94. type: "success"
  95. });
  96. }
  97. if (runMode !== "" && runMode !== "2" && val === "2"){
  98. return new Promise((resolve,reject)=>{
  99. orderMgrApi.getOrderStatusCount({}).then(res => {
  100. resolve(res)
  101. //console.log(res)
  102. if(res.data.isSuccess){
  103. this.orderCount = parseInt(res.data.data.orderConductCount)
  104. if(this.orderCount > 0){
  105. this.$message({
  106. message: "系统有在生产的订单,请先完成订单",
  107. type: "error"
  108. })
  109. this.bool = false
  110. this.$emit("close")
  111. }
  112. }
  113. })
  114. })
  115. }
  116. if(this.bool){
  117. this.tenant.runMode = val
  118. }
  119. },
  120. submitForm () {
  121. this.$refs.form.validate((valid) => {
  122. if (valid && this.bool) {
  123. // 获取父组件传值ID
  124. this.tenant.id = this.rowData.id
  125. this.confirmDisabled = true
  126. console.log(this.tenant)
  127. //productionLineMgrApi.update(this.tenant).then(res => {
  128. areaMgrApi.changeMode(this.tenant).then(res => {
  129. res = res.data
  130. console.log("恢复按钮 == ", res);
  131. // 恢复按钮
  132. this.confirmDisabled = false
  133. if (res.isSuccess) {
  134. this.$message({
  135. message: this.$t('tips.optionSuccess'),
  136. type: 'success'
  137. })
  138. } else {
  139. this.$message({
  140. message: res.message,
  141. type: "error"
  142. })
  143. }
  144. })
  145. } else {
  146. return false
  147. }
  148. })
  149. this.$emit("close")
  150. //location.reload()
  151. },
  152. checkCount(){
  153. }
  154. }
  155. }
  156. </script>
  157. <!-- 本组件的css -->
  158. <style lang="scss" scoped>
  159. .formTitle{
  160. font-size: 16px;
  161. font-weight: 700;
  162. margin: 30px 30px 20px 30px;
  163. padding-bottom: 20px;
  164. border-bottom: 1px solid #CCCCCC;
  165. }
  166. .formContaner form{
  167. max-width: 600px;
  168. }
  169. .dialog-footer{
  170. margin-left: 180px;
  171. }
  172. </style>