addEdit-newApply.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :center="true"
  5. align="left"
  6. top="5vh"
  7. width="1040px"
  8. @close="closeModel"
  9. :close-on-click-modal="false"
  10. :visible.sync="showModelThis"
  11. v-loading="loading"
  12. element-loading-text="拼命加载中"
  13. element-loading-spinner="el-icon-loading"
  14. element-loading-background="rgba(0, 0, 0, 0.8)"
  15. >
  16. <el-card>
  17. <el-row :gutter="10">
  18. <el-col :span="24">
  19. <ex-table
  20. v-loading="false"
  21. :table="table"
  22. :data="tableData"
  23. :columns="columns"
  24. :page="pageInfo"
  25. :size="size"
  26. @page-curr-change="handlePageChange"
  27. @page-size-change="handleSizeChange"
  28. @screen-reset="
  29. pageInfo.curr = 1;
  30. parmValue.page = 1;
  31. searchList();
  32. "
  33. @screen-submit="
  34. pageInfo.curr = 1;
  35. parmValue.page = 1;
  36. searchList();
  37. "
  38. >
  39. <template #table-header="{}">
  40. <div style="width: 100%; height: 40px"></div>
  41. </template>
  42. </ex-table>
  43. </el-col>
  44. <el-col :span="24" style="text-align: right; margin-top: 10px">
  45. <el-button type="primary" @click="save">保 存 </el-button>
  46. <!-- <el-button type="warning" @click="submitForm"
  47. >保 存 并 发 起 流 程
  48. </el-button> -->
  49. </el-col>
  50. </el-row>
  51. </el-card>
  52. </el-dialog>
  53. </template>
  54. <script>
  55. import asyncRequest from "@/apis/service/stock/newApply";
  56. import resToken from "@/mixins/resToken";
  57. import {
  58. isnumber,
  59. isMobile,
  60. validEmail,
  61. isAlphanumeric,
  62. isChinese,
  63. isEmoticon,
  64. validAlphabets,
  65. } from "@/utils/validate";
  66. export default {
  67. name: "newApply",
  68. props: ["showModel", "id", "isDetail", "sitem"],
  69. mixins: [resToken],
  70. data() {
  71. const validateusername = (rule, value, callback) => {
  72. // if (value === "") {
  73. // callback(new Error("账号不能为空!"));
  74. // } else {
  75. // if (value.length < 6 || value.length > 18) {
  76. // callback(new Error("账号规则为6~18位数字与字母组合!"));
  77. // } else {
  78. // if (isnumber(value)) {
  79. // callback(new Error("账号规则为6~18位数字与字母组合!"));
  80. // } else if (validAlphabets(value)) {
  81. // callback(new Error("账号规则为6~18位数字与字母组合!"));
  82. // } else if (!isAlphanumeric(value)) {
  83. // callback(new Error("账号规则为6~18位数字与字母组合!"));
  84. // } else {
  85. // callback();
  86. // }
  87. // }
  88. // }
  89. };
  90. const validatename = (rule, value, callback) => {
  91. // if (value === "") {
  92. // callback(new Error("真实姓名不能为空!"));
  93. // } else {
  94. // if (value.length < 2 || value.length > 12) {
  95. // callback(new Error("真实姓名规则为2~12位汉字!"));
  96. // } else {
  97. // if (!isChinese(value)) {
  98. // console.log(9999);
  99. // callback(new Error("真实姓名规则为2~12位汉字!"));
  100. // } else if (isEmoticon(value)) {
  101. // console.log(2345);
  102. // callback(new Error("真实姓名规则为2~12位汉字!"));
  103. // } else {
  104. // callback();
  105. // }
  106. // }
  107. // }
  108. };
  109. const validatemobile = (rule, value, callback) => {
  110. // if (value === "") {
  111. // callback(new Error("手机号不能为空!"));
  112. // } else {
  113. // if (!isMobile(value)) {
  114. // callback(new Error("手机号格式不正确!"));
  115. // } else {
  116. // callback();
  117. // }
  118. // }
  119. };
  120. const validateEmail = (rule, value, callback) => {
  121. // if (value === "") {
  122. // callback();
  123. // } else {
  124. // if (!validEmail(value)) {
  125. // callback(new Error("邮箱格式不正确!"));
  126. // } else {
  127. // callback();
  128. // }
  129. // }
  130. };
  131. return {
  132. loading: true,
  133. showModel: false,
  134. isDetail: false,
  135. modelId: 0,
  136. tableData: [], //渲染表格
  137. //
  138. // 表格 - 数据
  139. tableData: [],
  140. // 表格 - 参数
  141. table: {
  142. stripe: true,
  143. border: true,
  144. // _defaultHeader_: ["setcol"],
  145. },
  146. // 表格 - 分页
  147. pageInfo: {
  148. size: 15,
  149. curr: 1,
  150. total: 0,
  151. },
  152. // 表格 - 列参数
  153. columns: [
  154. {
  155. prop: "nickname",
  156. label: "商品编号",
  157. },
  158. {
  159. prop: "role_name",
  160. label: "商品名称",
  161. },
  162. {
  163. prop: "mobile",
  164. label: "数量",
  165. },
  166. ],
  167. loading: false,
  168. title: "添加账号",
  169. showModelThis: this.showModel,
  170. ruleForm: {
  171. username: "", // 账号
  172. name: "", // 真实姓名
  173. mobile: "",
  174. email: "",
  175. role_id: "",
  176. status: "1",
  177. item: [],
  178. },
  179. rulesThis: this.rules,
  180. rules: {
  181. name: [
  182. {
  183. required: true,
  184. validator: validatename,
  185. trigger: "blur",
  186. },
  187. ],
  188. username: [
  189. {
  190. required: true,
  191. validator: validateusername,
  192. trigger: "blur",
  193. },
  194. ],
  195. mobile: [
  196. {
  197. required: true,
  198. validator: validatemobile,
  199. trigger: "blur",
  200. },
  201. ],
  202. email: [
  203. {
  204. required: false,
  205. validator: validateEmail,
  206. trigger: "blur",
  207. },
  208. ],
  209. role_id: [
  210. {
  211. required: true,
  212. message: "请选择角色",
  213. trigger: "change",
  214. },
  215. ],
  216. item: [
  217. {
  218. type: "array",
  219. required: true,
  220. message: "请选择所在部门",
  221. trigger: "change",
  222. },
  223. ],
  224. status: [
  225. {
  226. required: true,
  227. message: "请选择状态",
  228. trigger: "change",
  229. },
  230. ],
  231. },
  232. };
  233. },
  234. watch: {
  235. showModel: function (val) {
  236. this.showModelThis = val;
  237. if (val) {
  238. this.initForm();
  239. }
  240. },
  241. showModelThis(val) {
  242. if (!val) {
  243. this.$emit("cancel");
  244. }
  245. },
  246. },
  247. methods: {
  248. closeModel() {
  249. console.log("closeModel!!");
  250. },
  251. async initForm() {
  252. this.loading = true;
  253. this.title = "可调拨的商品";
  254. {
  255. //await this.getRole();
  256. // if (this.id === "add") {
  257. // this.title = "添加账号";
  258. // this.rulesThis = this.rules;
  259. // await this.resetForm();
  260. // } else {
  261. // if (this.isDetail) {
  262. // this.title = "账号详情";
  263. // this.rulesThis = {};
  264. // } else {
  265. // this.title = "修改账号";
  266. // this.rulesThis = this.rules;
  267. // }
  268. // await this.resetForm(this.sitem);
  269. // // await this.initData()
  270. //}
  271. }
  272. this.loading = false;
  273. },
  274. // async getRole() {
  275. // const model = {
  276. // status: "", // 状态
  277. // level: "", // 姓名
  278. // role_name: "",
  279. // };
  280. // const res = await asyncRequest.getRole(model);
  281. // if (res && res.code === 0 && res.data) {
  282. // this.roleList = res.data;
  283. // this.roleList.map((v1) => {
  284. // v1.id += "";
  285. // v1.status += "";
  286. // return v1;
  287. // });
  288. // }
  289. // },
  290. async initData() {
  291. // const res = await asyncRequest.detail({ id: this.id });
  292. // if (res && res.code === 0 && res.data) {
  293. // this.ruleForm = res.data;
  294. // this.ruleForm.role_id = this.ruleForm.role;
  295. // } else if (res && res.code >= 100 && res.code <= 104) {
  296. // await this.logout();
  297. // } else {
  298. // this.$message.warning(res.message);
  299. // }
  300. },
  301. async resetForm(sitem) {
  302. // 重置
  303. await this.$nextTick(() => {
  304. // if (this.$refs.ruleForm) {
  305. // this.$refs.ruleForm.resetFields();
  306. // this.$refs.ruleForm.clearValidate();
  307. // const { username, nickname, mobile, email, roleid, status, item } =
  308. // sitem;
  309. // this.ruleForm = {
  310. // username: username || "", // 账号
  311. // name: nickname || "", // 真实姓名
  312. // mobile: mobile || "",
  313. // email: email || "",
  314. // role_id: roleid || "",
  315. // status: status || "",
  316. // item: item || [],
  317. // };
  318. // if (this.id === "add" || this.isDetail) {
  319. // this.rules.username[0].required = false;
  320. // }
  321. // }
  322. });
  323. },
  324. save() {
  325. console.log("点击了保存");
  326. this.showModel = false;//关闭弹窗,
  327. },
  328. async submitForm() {
  329. console.log("点击了保存并发起流程");
  330. // await this.$refs.ruleForm.validate(async (valid) => {
  331. // if (valid) {
  332. // this.loading = true;
  333. // const { username, name, mobile, email, role_id, status } = JSON.parse(
  334. // JSON.stringify(this.ruleForm)
  335. // );
  336. // const model = {
  337. // id: this.id,
  338. // username: username || "", // 账号
  339. // nickname: name || "", // 真实姓名
  340. // mobile: mobile || "",
  341. // email: email || "",
  342. // role: role_id || "",
  343. // status: status || "",
  344. // };
  345. // let res = {};
  346. // if (this.id === "add") {
  347. // delete model["id"];
  348. // res = await asyncRequest.add(model);
  349. // } else {
  350. // res = await asyncRequest.update(model);
  351. // }
  352. // this.loading = false;
  353. // if (res && res.code === 0) {
  354. // const title = this.id === "add" ? "添加成功" : "修改成功";
  355. // this.$notify.success({
  356. // title,
  357. // message: "",
  358. // });
  359. // this.showModelThis = false;
  360. // // 刷新
  361. // this.$emit("refresh");
  362. // } else if (res && res.code >= 100 && res.code <= 104) {
  363. // await this.logout();
  364. // } else {
  365. // this.$message.warning(res.message);
  366. // }
  367. // } else {
  368. // console.log("error submit!!");
  369. // return false;
  370. // }
  371. // });
  372. },
  373. },
  374. };
  375. </script>
  376. <style lang="scss" scoped>
  377. .setcol-table-lie {
  378. display: none !important;
  379. }
  380. </style>