editForm.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <a-form :form="form" ref="form">
  3. <a-row class="form-row" :gutter="24">
  4. <a-col :xl="6" :lg="8" :md="12" :sm="24" class="form-col">
  5. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点单号">
  6. <a-input disabled placeholder="请输入" v-decorator="['number']" />
  7. </a-form-item>
  8. </a-col>
  9. <a-col :xl="6" :lg="8" :md="12" :sm="24" class="form-col">
  10. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点类型">
  11. <a-select
  12. placeholder="请选择"
  13. @change="emitForm"
  14. v-decorator="['taskType', rules.taskType]"
  15. :options="taskTypeList"
  16. :disabled="isDisabled"
  17. >
  18. </a-select>
  19. </a-form-item>
  20. </a-col>
  21. <a-col :xl="6" :lg="8" :md="12" :sm="24" class="form-col">
  22. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" required prop="taskName" label="盘点任务名称">
  23. <a-input placeholder="请输入" :disabled="isDisabled" v-decorator="['taskName', rules.taskName]" />
  24. </a-form-item>
  25. </a-col>
  26. <a-col :xl="6" :lg="8" :md="12" :sm="24" class="form-col">
  27. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="depotId" label="盘点仓库">
  28. <a-select
  29. placeholder="请选择"
  30. v-decorator="['depotId', rules.depotId]"
  31. :options="depotList"
  32. :disabled="isDisabled"
  33. @change="emitForm"
  34. >
  35. </a-select>
  36. </a-form-item>
  37. </a-col>
  38. <a-col :xl="6" :lg="8" :md="12" :sm="24" class="form-col">
  39. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点负责人">
  40. <a-select placeholder="请选择" v-decorator="['creator']" :options="spinnerList" :disabled="isDisabled">
  41. </a-select>
  42. </a-form-item>
  43. </a-col>
  44. <a-col :xl="6" :lg="8" :md="12" :sm="24" class="form-col">
  45. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="创建人">
  46. <a-input placeholder="请输入" v-decorator="['createByName']" disabled />
  47. </a-form-item>
  48. </a-col>
  49. <a-col :xl="6" :lg="8" :md="12" :sm="24" class="form-col">
  50. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="创建时间">
  51. <a-input placeholder="请输入" disabled v-decorator="['createTime']" />
  52. </a-form-item>
  53. </a-col>
  54. <a-col :xl="6" :lg="8" :md="12" :sm="24" class="form-col">
  55. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点库位范围">
  56. <a-input placeholder="请输入" v-decorator="['positionRange']" disabled />
  57. </a-form-item>
  58. </a-col>
  59. <a-col :xl="6" :lg="8" :md="12" :sm="24" class="form-col">
  60. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="商品数量">
  61. <a-input disabled placeholder="请输入" v-decorator="['materialCount']" />
  62. </a-form-item>
  63. </a-col>
  64. <a-col v-if="stockType === 'check'" :xl="6" :lg="8" :md="12" :sm="24" class="form-col">
  65. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点人">
  66. <a-input placeholder="请输入" disabled v-decorator.trim="['operBy']" />
  67. </a-form-item>
  68. </a-col>
  69. <a-col v-if="stockType === 'check'" :xl="6" :lg="8" :md="12" :sm="24" class="form-col">
  70. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="完成时间">
  71. <a-input placeholder="请输入" disabled v-decorator.trim="['operTime']" />
  72. </a-form-item>
  73. </a-col>
  74. <a-col v-show="true" :xl="6" :lg="8" :md="12" :sm="24" class="form-col">
  75. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点状态">
  76. <a-select placeholder="请选择" v-decorator="['taskStatus']" :options="taskStatusList" :disabled="isDisabled">
  77. </a-select>
  78. </a-form-item>
  79. </a-col>
  80. <a-col v-show="false" :xl="6" :lg="8" :md="12" :sm="24" class="form-col">
  81. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点状态">
  82. <a-input v-decorator="['id']"></a-input>
  83. </a-form-item>
  84. </a-col>
  85. </a-row>
  86. </a-form>
  87. </template>
  88. <script>
  89. import pick from 'lodash.pick'
  90. export default {
  91. name: 'EditForm',
  92. props: {
  93. // form: {
  94. // type: Object,
  95. // default: null,
  96. // },
  97. rules: {
  98. type: Object,
  99. default: () => {
  100. return {}
  101. },
  102. },
  103. spinnerList: {
  104. type: Array,
  105. default: () => {
  106. return []
  107. },
  108. },
  109. depotList: {
  110. type: Array,
  111. default: () => {
  112. return []
  113. },
  114. },
  115. stockVisible: {
  116. type: Boolean,
  117. default: false,
  118. },
  119. total: {
  120. type: [Number, String],
  121. default: 0,
  122. },
  123. openType: {
  124. type: String,
  125. default: 'add',
  126. },
  127. stockType: {
  128. type: String,
  129. default: '',
  130. },
  131. },
  132. data() {
  133. return {
  134. taskStatusList: [
  135. { value: 1, label: '未开始' },
  136. { value: 2, label: '进行中' },
  137. { value: 3, label: '已完成' },
  138. { value: 4, label: '已取消' },
  139. ],
  140. labelCol: {
  141. xs: { span: 24 },
  142. sm: { span: 8 },
  143. },
  144. wrapperCol: {
  145. xs: { span: 24 },
  146. sm: { span: 16 },
  147. },
  148. taskTypeList: [
  149. { value: 1, label: '全盘' },
  150. { value: 2, label: '抽盘' },
  151. ],
  152. validatorRules: {},
  153. model: {},
  154. form: this.$form.createForm(this),
  155. }
  156. },
  157. watch: {
  158. total(val) {
  159. this.form.setFieldsValue({ materialCount: val })
  160. },
  161. // 监听弹窗显示隐藏,重置表单数据
  162. stockVisible: {
  163. handler(val) {
  164. if (!val) {
  165. this.form.resetFields()
  166. this.emitForm()
  167. }
  168. if (this.openType === 'add') {
  169. this.model.taskStatus = 1
  170. this.$nextTick(() => {
  171. this.form.setFieldsValue({ taskStatus: 1 })
  172. })
  173. }
  174. },
  175. immediate: true,
  176. deep: true,
  177. },
  178. },
  179. computed: {
  180. isDisabled() {
  181. return this.openType === 'detail' || this.model.taskStatus !== 1
  182. },
  183. },
  184. methods: {
  185. emitForm(val){
  186. this.$nextTick(() => {
  187. this.$emit('changeForm', this.form.getFieldsValue())
  188. })
  189. }
  190. },
  191. }
  192. </script>
  193. <style lang="less">
  194. .ant-input-disabled {
  195. background-color: rgb(255, 255, 255, 0.2) !important;
  196. }
  197. .ant-select-disabled {
  198. background-color: rgba(255, 255, 255, 0.2) !important;
  199. }
  200. </style>