program-add-or-update.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <div>
  3. <div class="my-title">{{ !id ? "新增" : "修改" }}</div>
  4. <el-form
  5. :model="dataForm"
  6. :rules="dataRule"
  7. ref="dataForm"
  8. label-width="180px"
  9. >
  10. <el-row>
  11. <el-col :span="6">
  12. <el-form-item label="物料名称" prop="productId">
  13. <el-select
  14. v-model="dataForm.productId"
  15. filterable
  16. remote
  17. clearable
  18. placeholder="请选择"
  19. >
  20. <el-option
  21. v-for="item in materialList"
  22. :key="item.materialId"
  23. :label="item.materialName"
  24. :value="item.materialId"
  25. >
  26. </el-option>
  27. </el-select>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="6">
  31. <el-form-item label="程序编码" prop="programCode">
  32. <el-input
  33. v-model="dataForm.programCode"
  34. placeholder="请输入"
  35. ></el-input>
  36. </el-form-item>
  37. </el-col>
  38. </el-row>
  39. <el-row>
  40. <el-col :span="12">
  41. <el-form-item label="程序说明" prop="programInstructions">
  42. <el-input
  43. v-model="dataForm.programInstructions"
  44. placeholder="请输入"
  45. type="textarea"
  46. ></el-input>
  47. </el-form-item>
  48. </el-col>
  49. <el-col :span="12">
  50. <el-form-item label="备注说明" prop="remark">
  51. <el-input
  52. v-model="dataForm.remark"
  53. placeholder="请输入"
  54. type="textarea"
  55. ></el-input>
  56. </el-form-item>
  57. </el-col>
  58. </el-row>
  59. <el-row>
  60. <el-col :span="8">
  61. <el-form-item label="程序包" prop="cxbList">
  62. <upload-component
  63. :display="false"
  64. :displayStar="false"
  65. :accept="'*'"
  66. v-model="dataForm.cxbList"
  67. @uploadSuccess="uploadSuccess"
  68. />
  69. </el-form-item>
  70. </el-col>
  71. <el-col :span="8" :offset="4">
  72. <el-form-item label="数控加工程序单" prop="skjgList">
  73. <upload-component
  74. :display="false"
  75. :displayStar="false"
  76. :accept="'*'"
  77. v-model="dataForm.skjgList"
  78. @uploadSuccess="uploadSuccess"
  79. />
  80. </el-form-item>
  81. </el-col>
  82. </el-row>
  83. <el-row>
  84. <el-col :span="8">
  85. <el-form-item label="防真验证情况记录表" prop="fzyzList">
  86. <upload-component
  87. :display="false"
  88. :displayStar="false"
  89. :accept="'*'"
  90. v-model="dataForm.fzyzList"
  91. @uploadSuccess="uploadSuccess"
  92. />
  93. </el-form-item>
  94. </el-col>
  95. <el-col :span="8" :offset="4">
  96. <el-form-item label="数控加工程序试切鉴定表" prop="cxsqList">
  97. <upload-component
  98. :display="false"
  99. :displayStar="false"
  100. :accept="'*'"
  101. v-model="dataForm.cxsqList"
  102. @uploadSuccess="uploadSuccess"
  103. />
  104. </el-form-item>
  105. </el-col>
  106. </el-row>
  107. </el-form>
  108. <span slot="footer" class="dialog-footer">
  109. <el-button @click="onChose">取消</el-button>
  110. <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
  111. </span>
  112. </div>
  113. </template>
  114. <script>
  115. import { getMaterialList } from '@/api/material'
  116. import uploadComponent from '../common/upload-component-v2'
  117. export default {
  118. name: 'program-add-or-update',
  119. components: {uploadComponent},
  120. data () {
  121. return {
  122. id: 0,
  123. dataForm: {},
  124. materialList: [],
  125. dataRule: {
  126. productName: [{required: true, message: '请选择物料名称', trigger: 'change'}],
  127. programCode: [{required: true, message: '请输入程序编码', trigger: 'blur'}],
  128. programInstructions: [{required: true, message: '请输入程序说明', trigger: 'blur'}],
  129. cxbList: [{required: true, message: '请上传文件', trigger: 'blur'}],
  130. skjgList: [{required: true, message: '请上传文件', trigger: 'blur'}],
  131. fzyzList: [{required: true, message: '请上传文件', trigger: 'blur'}],
  132. cxsqList: [{required: true, message: '请上传文件', trigger: 'blur'}]
  133. }
  134. }
  135. },
  136. created () {
  137. },
  138. methods: {
  139. init (id, item) {
  140. this.id = id || 0
  141. if (item) {
  142. if (item.cxbList) {
  143. item.cxbList.forEach(t => { t.name = t.fileName })
  144. }
  145. if (item.cxsqList) {
  146. item.cxsqList.forEach(t => { t.name = t.fileName })
  147. }
  148. if (item.fzyzList) {
  149. item.fzyzList.forEach(t => { t.name = t.fileName })
  150. }
  151. if (item.skjgList) {
  152. item.skjgList.forEach(t => { t.name = t.fileName })
  153. }
  154. this.dataForm = {...item}
  155. }
  156. this.getMaterialList()
  157. },
  158. onChose () {
  159. this.$emit('onChose')
  160. },
  161. getMaterialList () {
  162. getMaterialList().then(({ data }) => {
  163. if (data && data.code === '200') {
  164. this.materialList = data.data.records
  165. }
  166. })
  167. },
  168. dataFormSubmit () {
  169. this.$refs['dataForm'].validate((valid) => {
  170. if (valid) {
  171. this.$http({
  172. url: !this.id
  173. ? this.$http.adornUrl(`/biz-service/pro-program/save`)
  174. : this.$http.adornUrl(`/biz-service/pro-program/update`),
  175. method: 'post',
  176. data: this.$http.adornData({ ...this.dataForm, orgId: this.orgId })
  177. }).then(({ data }) => {
  178. if (data && data.code === '200') {
  179. this.$message({
  180. message: '操作成功',
  181. type: 'success',
  182. duration: 1500,
  183. onClose: () => {
  184. this.onChose()
  185. this.$emit('refreshDataList')
  186. }
  187. })
  188. } else {
  189. this.$message.error(data.msg)
  190. }
  191. })
  192. }
  193. })
  194. },
  195. uploadSuccess () {}
  196. }
  197. }
  198. </script>
  199. <style>
  200. </style>