online-exam-form.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <el-form
  3. v-loading="loading"
  4. ref="ruleForm"
  5. :model="ruleForm"
  6. status-icon
  7. :rules="rulesThis"
  8. :label-width="labelWidth || '100px'"
  9. class="demo-ruleForm"
  10. :size="size || 'medium'"
  11. >
  12. <el-row>
  13. <el-col :span="6"
  14. ><el-form-item label="审核状态" prop="state">
  15. <el-radio-group
  16. v-model="ruleForm.state"
  17. placeholder="请选择审核状态"
  18. style="width: 100%"
  19. :size="size || 'medium'"
  20. @change="stateChange"
  21. >
  22. <el-radio v-for="item in stateList" :key="item.value" :label="item.value">{{
  23. item.label
  24. }}</el-radio>
  25. </el-radio-group>
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="18" v-if="ruleForm.state === '1'">
  29. <el-row>
  30. <el-col :span="14">
  31. <el-form-item label="有赞公用分类" prop="cat" label-width="120px">
  32. <el-input
  33. v-model="ruleForm.cat"
  34. placeholder="有赞公用分类"
  35. :size="'mini'"
  36. maxlength="20"
  37. />
  38. </el-form-item>
  39. <el-form-item label="是否可退货" prop="is_return" label-width="120px">
  40. <el-radio-group
  41. v-model="ruleForm.is_return"
  42. placeholder="请选择是否可退货"
  43. style="width: 100%"
  44. :size="'mini'"
  45. >
  46. <el-radio
  47. v-for="item in is_return_list"
  48. :key="item.value"
  49. :label="item.value"
  50. >{{ item.label }}</el-radio
  51. >
  52. </el-radio-group>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="10">
  56. <el-form-item label="系统售价" prop="new_sale_price" required>
  57. <el-input
  58. v-model="ruleForm.new_sale_price"
  59. placeholder="系统售价"
  60. :disabled="true"
  61. :size="'mini'"
  62. maxlength="20"
  63. >
  64. <template slot="append">元</template>
  65. </el-input>
  66. </el-form-item>
  67. <el-form-item label="最终售价" prop="sale_price">
  68. <digital-input
  69. :values="ruleForm.sale_price"
  70. :placeholder="'售价'"
  71. :min="0"
  72. :max="100000000000"
  73. :position="'right'"
  74. :precision="2"
  75. :controls="false"
  76. :append="'元'"
  77. :newTime="ruleForm.newTime"
  78. :size="'mini'"
  79. :disabled="!ruleForm.edit"
  80. @reschange="num_change($event, 'sale_price', scope.$index)"
  81. /> </el-form-item
  82. ></el-col>
  83. </el-row>
  84. </el-col>
  85. <el-col :span="18" v-else>
  86. <el-form-item label="审核备注" prop="remark">
  87. <el-input
  88. type="textarea"
  89. placeholder="审核备注"
  90. v-model="ruleForm.remark"
  91. :disabled="disabled"
  92. maxlength="250"
  93. show-word-limit
  94. :autosize="{ minRows: 3, maxRows: 3 }"
  95. />
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="24">
  99. <el-form-item class="fr">
  100. <el-button
  101. v-if="!isDetail"
  102. :size="'mini'"
  103. type="primary"
  104. @click="submitForm(ruleForm.state === '1' ? '3' : '')"
  105. >保 存
  106. </el-button>
  107. </el-form-item>
  108. </el-col>
  109. </el-row>
  110. </el-form>
  111. </template>
  112. <script>
  113. export default {
  114. name: "exam-form",
  115. props: ["size", "statusList", "disabled", "isMust", "labelWidth", "time"],
  116. /**
  117. * 属性集合
  118. * @param {String} size : 组件大小 非必填
  119. * @param {Array} statusList : 驳回至备选项 必填
  120. * @param {Boolean} disabled : 是否禁用 必填
  121. * @param {Boolean} isMust : 是否需要展示驳回节点 必填
  122. *
  123. *
  124. */
  125. /**
  126. * 事件集合
  127. * @searchChange : 选中值变化调用 抛出选中数据
  128. */
  129. data() {
  130. return {
  131. loading: false,
  132. stateList: [
  133. {
  134. value: "1",
  135. label: "通过",
  136. },
  137. {
  138. value: "0",
  139. label: "驳回",
  140. },
  141. ],
  142. is_return_list: [
  143. {
  144. value: "1",
  145. label: "支持退货",
  146. },
  147. {
  148. value: "0",
  149. label: "不支持退货",
  150. },
  151. ],
  152. showModelThis: this.showModel,
  153. pickerOptions: {
  154. disabledDate(time) {
  155. return time.getTime() < Date.now() - 60 * 60 * 24 * 1000;
  156. },
  157. },
  158. ruleForm: {
  159. numStatus: "", //点击的按钮状态
  160. state: "1", // 通过or驳回
  161. rebut: "", //驳回至
  162. remark: "",
  163. },
  164. rulesThis: this.rules,
  165. rules: {
  166. state: [
  167. {
  168. required: true,
  169. message: "请选择审核状态",
  170. trigger: "change",
  171. },
  172. ],
  173. is_return: [
  174. {
  175. required: true,
  176. message: "请选择是否可退",
  177. trigger: "change",
  178. },
  179. ],
  180. cat: [
  181. {
  182. required: true,
  183. message: "请选择有赞公用分类",
  184. trigger: "change",
  185. },
  186. ],
  187. sale_price: [
  188. {
  189. required: true,
  190. message: "请选择有赞公用分类",
  191. trigger: "blur",
  192. },
  193. ],
  194. remark: [
  195. { required: true, message: "请输入审核备注", trigger: "blur" },
  196. {
  197. min: 1,
  198. max: 250,
  199. message: "长度在 1 到 250 个字符",
  200. trigger: "blur",
  201. },
  202. ],
  203. },
  204. };
  205. },
  206. watch: {
  207. isDetail: function (val, old) {
  208. if (this.isDetail !== val) {
  209. this.options = [];
  210. this.selectLoading = false;
  211. }
  212. },
  213. newTime: function (val) {
  214. if (val) {
  215. this.initForm();
  216. }
  217. },
  218. },
  219. mounted() {
  220. this.initForm();
  221. },
  222. methods: {
  223. async initForm() {
  224. // this.loading = true;
  225. this.rulesThis = this.rules;
  226. await this.resetForm();
  227. this.stateChange();
  228. this.loading = false;
  229. },
  230. stateChange() {
  231. if (this.ruleForm.state === "1") {
  232. this.rulesThis.rebut[0].required = false;
  233. this.rulesThis.remark[0].required = false;
  234. } else {
  235. this.rulesThis.rebut[0].required = true;
  236. this.rulesThis.remark[0].required = true;
  237. }
  238. },
  239. async resetForm() {
  240. // 重置
  241. await this.$nextTick(() => {
  242. if (this.$refs.ruleForm) {
  243. this.$refs.ruleForm.resetFields();
  244. this.$refs.ruleForm.clearValidate();
  245. this.ruleForm = {
  246. state: "1", // 通过or驳回
  247. rebut: "", //驳回至
  248. remark: "",
  249. };
  250. }
  251. });
  252. },
  253. async submitForm(numStatus) {
  254. this.ruleForm.numStatus = numStatus;
  255. //点击驳回重新审核时,调用其他接口
  256. await this.$refs.ruleForm.validate(async (valid) => {
  257. if (valid) {
  258. this.$emit("searchChange", this.ruleForm);
  259. } else {
  260. console.log("error submit!!");
  261. return false;
  262. }
  263. });
  264. },
  265. },
  266. };
  267. </script>
  268. <style></style>