step-project.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <div class="sign-new-project">
  3. <div class="sign-new-tips">
  4. 项目是最重要的信息;据客栈统计,<b>83%</b>的客户特别倾向有类似项目经历,且信息完善的开发者!
  5. </div>
  6. <div class="sign-project-main">
  7. <header class="sign-new-header">
  8. <div class="sign-new-header-title">作品(3-5个项目)</div>
  9. </header>
  10. <section class="sign-new-works-list">
  11. <div v-if="works.length > 0">
  12. <template v-for="(item, idx) in works">
  13. <div
  14. v-if="editingItem.indexOf(idx) < 0"
  15. :key="`works_${idx}`"
  16. class="show"
  17. >
  18. <span
  19. class="image"
  20. :style="{
  21. 'background-image': `url('${works[idx].image_list[0].url}')`
  22. }"
  23. v-if="works[idx].image_list && works[idx].image_list[0]"
  24. >
  25. </span>
  26. <div class="des">
  27. <div class="des-title">
  28. <div class="des-title-name text-line-1">{{ item.name }}</div>
  29. <div class="des-title-time">{{ item.update_time_name }}</div>
  30. </div>
  31. <div class="des-content text-line-3">
  32. {{ item.description }}
  33. </div>
  34. <div class="des-state">
  35. <div class="des-state-item fl">
  36. <img
  37. src="~@/assets/img/svg/read.svg"
  38. class="des-state-icon"
  39. />
  40. <span>{{ item.browse }}</span>
  41. </div>
  42. <div class="des-state-item fl">
  43. <img
  44. src="~@/assets/img/svg/like.svg"
  45. class="des-state-icon"
  46. />
  47. <span>{{ item.hit }}</span>
  48. </div>
  49. <div class="des-state-item fr">
  50. <img
  51. src="~@/assets/img/svg/del.svg"
  52. class="des-state-icon"
  53. />
  54. </div>
  55. <div class="des-state-item fr" @click="editItem(idx)">
  56. <img
  57. src="~@/assets/img/svg/edit.svg"
  58. class="des-state-icon"
  59. />
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. <work-form
  65. v-else
  66. :key="`works_edit_${idx}`"
  67. :idx="idx"
  68. :work="works[idx]"
  69. :industries="industries"
  70. :functions="functions"
  71. :handleCancel="handleCancel"
  72. :onSubmit="onSubmit"
  73. :handleDelete="handleDelete"
  74. ></work-form>
  75. </template>
  76. <div class="sign-new-project-add" @click="handleAdd">
  77. <img
  78. src="~@/assets/img/svg/add-project.svg"
  79. class="sign-new-project-add-icon"
  80. />
  81. <div class="sign-new-project-add-tips">添加作品</div>
  82. </div>
  83. </div>
  84. <div v-else class="empty">
  85. 点击右上角“添加”按钮添加作品(至少添加1项)
  86. </div>
  87. </section>
  88. </div>
  89. <div class="sign-new-next">
  90. <div class="sign-new-next-btn">下一步</div>
  91. </div>
  92. </div>
  93. </template>
  94. <script>
  95. import { mapState } from "vuex";
  96. import qs from "qs";
  97. import workForm from "./work-form";
  98. export default {
  99. data() {
  100. return {
  101. // editing: true,
  102. editingItem: [],
  103. init: {
  104. name: "",
  105. industry_id: "",
  106. function_ops: "",
  107. duty: "",
  108. description: "",
  109. url: "",
  110. image_list: []
  111. },
  112. works: [],
  113. current: null,
  114. originWorks: [],
  115. industries: [],
  116. functions: []
  117. };
  118. },
  119. components: {
  120. workForm
  121. },
  122. computed: {
  123. ...mapState(["userinfo"])
  124. },
  125. watch: {},
  126. async mounted() {
  127. await this.getIndustry();
  128. this.getFunction();
  129. this.getData();
  130. },
  131. methods: {
  132. async onSubmit(work, idx) {
  133. const queryParams = {
  134. ...work,
  135. // id: 1, //传ID是更新,不传ID是新增
  136. // name: "作品名称",
  137. // duty: "作品指责",
  138. // description: "作品描述",
  139. function_ops: work.function_ops.join(","), //是多个ID,用英文逗号分割,关键功能
  140. industry_id: parseInt(work.industry_id[1]), //id,是int类型啊,不是文字
  141. // url: "https://a.com",
  142. image_list: work.image_list.map(it => it.url).join(",") //是图片地址,多个图片用逗号分割,
  143. };
  144. const res = await this.$axios.$post(`/api/user_works/save`, queryParams);
  145. if (res.status === 1) {
  146. this.$message.success("保存成功!");
  147. this.init = {
  148. name: "",
  149. industry_id: "",
  150. function_ops: "",
  151. duty: "",
  152. description: "",
  153. url: "",
  154. image_list: []
  155. };
  156. this.editingItem = [];
  157. this.getData();
  158. }
  159. },
  160. async getData() {
  161. const res = await this.$axios.$post("/api/user_works/get_list");
  162. const data = !res.data ? [] : res.data;
  163. this.works = data.map(it => {
  164. const image_list = it.image_list
  165. ? it.image_list.split(",").map(it => ({ name: it, url: it }))
  166. : [];
  167. let industry_id;
  168. this.industries.map(item1 => {
  169. return item1.children.map(item2 => {
  170. if (item2.value == it.industry_id) {
  171. industry_id = [item1.value, item2.value];
  172. }
  173. });
  174. });
  175. console.log(industry_id);
  176. return {
  177. ...it,
  178. industry_id,
  179. function_ops: it.function_ops ? it.function_ops.split(",") : [],
  180. image_list
  181. };
  182. });
  183. },
  184. async getIndustry() {
  185. const res = await this.$axios.$post("/api/user_works/get_industry");
  186. const data = !res.data ? [] : res.data;
  187. this.industries = data.map(it => ({
  188. label: it.name,
  189. value: it.id,
  190. children: it.child.map(it => ({
  191. label: it.name,
  192. value: it.id
  193. }))
  194. }));
  195. return this.industries;
  196. },
  197. async getFunction() {
  198. const res = await this.$axios.$post("/api/user_works/get_function");
  199. const data = !res.data ? [] : res.data;
  200. this.functions = data.map(it => ({
  201. label: it.outsourcefunc_name,
  202. value: it.outsourcefunc_id
  203. }));
  204. },
  205. async fetchWork(keyword) {
  206. // console.log(keyword);
  207. // this.loadingWork = true;
  208. // const res = await this.$axios.$post("/api/simple_data/select_skill", {
  209. // keyword
  210. // });
  211. // this.loadingWork = false;
  212. // const data = res.data || [];
  213. // this.skillList = data.map(it => ({ value: it.id, label: it.name }));
  214. },
  215. handleAdd() {
  216. if (this.userinfo && this.userinfo.realname_verify_status === "0") {
  217. this.$message.error("请先进行实名认证");
  218. return;
  219. }
  220. if (this.editingItem.length > 0 && !this.works[this.editingItem[0]].id) {
  221. this.$message.error("请先保存现有修改");
  222. return;
  223. }
  224. // this.works.push(this.init);
  225. // this.editingItem = [this.works.length - 1];
  226. window.location.href = "/otherpage/works/create";
  227. },
  228. async handleDelete(work, idx) {
  229. const deleteComplete = () => {
  230. this.$message({
  231. type: "success",
  232. message: "删除成功!"
  233. });
  234. this.works.splice(idx, 1);
  235. this.editingItem = [];
  236. };
  237. this.$confirm("确认删除该作品?", "提示", {
  238. confirmButtonText: "确定",
  239. cancelButtonText: "取消",
  240. type: "warning"
  241. })
  242. .then(async () => {
  243. if (work.wid) {
  244. const res = await this.$axios.$post(`/api/user_works/delete`, {
  245. id: work.wid
  246. });
  247. if (res.status === 1) {
  248. deleteComplete();
  249. // this.$message.success(res.info);
  250. this.getData();
  251. }
  252. } else {
  253. deleteComplete();
  254. }
  255. })
  256. .catch(err => {
  257. console.log(err);
  258. this.$message({
  259. type: "info",
  260. message: "已取消删除"
  261. });
  262. });
  263. },
  264. handleCancel(work, idx) {
  265. this.editingItem = [];
  266. if (!work.wid) {
  267. this.works.splice(idx, 1);
  268. }
  269. },
  270. editItem(idx) {
  271. // this.editingItem = [idx];
  272. window.location.href =
  273. "/otherpage/works/create?wid=" + this.works[idx].wid;
  274. }
  275. }
  276. };
  277. </script>
  278. <style lang="scss">
  279. .sign-project-main {
  280. header .el-icon-plus {
  281. font-size: 18px;
  282. }
  283. .show {
  284. display: flex;
  285. justify-content: space-between;
  286. padding: 30px 24px;
  287. background: #ffffff;
  288. border-radius: 8px;
  289. border: 1px solid #ced3d9;
  290. margin-bottom: 30px;
  291. &:last-of-type {
  292. /* border: 0; */
  293. margin-bottom: 30px;
  294. }
  295. .star {
  296. display: flex;
  297. flex-direction: column;
  298. align-items: center;
  299. justify-content: center;
  300. width: 100px;
  301. img {
  302. margin-bottom: 5px;
  303. width: 26px;
  304. height: 26px;
  305. }
  306. }
  307. .image {
  308. margin-right: 10px;
  309. width: 116px;
  310. height: 116px;
  311. overflow: hidden;
  312. background-position: 50% 50%;
  313. background-repeat: no-repeat;
  314. background-size: cover;
  315. }
  316. .des {
  317. flex: 1;
  318. display: flex;
  319. flex-direction: column;
  320. justify-content: space-between;
  321. }
  322. h4 {
  323. display: flex;
  324. justify-content: space-between;
  325. align-items: center;
  326. height: 24px;
  327. font-size: 14px;
  328. font-family: PingFangSC-Medium;
  329. font-weight: 500;
  330. color: #308eff;
  331. line-height: 24px;
  332. }
  333. p {
  334. font-size: 14px;
  335. font-family: PingFangSC-Regular;
  336. font-weight: 400;
  337. color: rgba(102, 102, 102, 1);
  338. line-height: 24px;
  339. }
  340. }
  341. .empty {
  342. margin: 112px auto 104px;
  343. font-size: 27px;
  344. font-family: PingFangSC-Regular;
  345. font-weight: 400;
  346. text-align: center;
  347. color: rgba(205, 205, 205, 1);
  348. line-height: 38px;
  349. }
  350. footer p {
  351. margin-top: 15px;
  352. width: 766px;
  353. font-size: 12px;
  354. font-family: PingFangSC-Regular;
  355. font-weight: 400;
  356. color: rgba(145, 154, 167, 1);
  357. line-height: 17px;
  358. }
  359. }
  360. .sign-project-main {
  361. margin-top: 60px;
  362. margin-bottom: 130px;
  363. .sign-new-header {
  364. border: none;
  365. }
  366. }
  367. .des-title {
  368. display: flex;
  369. justify-content: space-between;
  370. align-items: center;
  371. }
  372. .des-title-name {
  373. font-size: 16px;
  374. font-family: PingFangSC-Medium, PingFang SC;
  375. font-weight: 500;
  376. color: #0b111a;
  377. line-height: 21px;
  378. max-width: 35em;
  379. }
  380. .des-title-time {
  381. font-size: 13px;
  382. font-family: PingFangSC-Regular, PingFang SC;
  383. font-weight: 400;
  384. color: #828c99;
  385. line-height: 18px;
  386. }
  387. .des-content {
  388. margin-top: 8px;
  389. font-size: 13px;
  390. font-family: PingFangSC-Regular, PingFang SC;
  391. font-weight: 400;
  392. color: #828c99;
  393. line-height: 18px;
  394. }
  395. .des-state {
  396. margin-top: 15px;
  397. overflow: hidden;
  398. .fl {
  399. float: left;
  400. margin-right: 20px;
  401. .des-state-icon {
  402. margin-right: 4px;
  403. }
  404. }
  405. .fr {
  406. float: right;
  407. margin-left: 20px;
  408. .des-state-icon {
  409. cursor: pointer;
  410. }
  411. }
  412. }
  413. .des-state-icon {
  414. // width: 14px;
  415. height: 16px;
  416. }
  417. .des-state-item {
  418. display: flex;
  419. align-items: center;
  420. span {
  421. font-size: 12px;
  422. font-family: PingFangSC-Regular, PingFang SC;
  423. font-weight: 400;
  424. color: #828c99;
  425. }
  426. }
  427. .text-line-3 {
  428. display: -webkit-box;
  429. word-break: break-all;
  430. -webkit-box-orient: vertical;
  431. -webkit-line-clamp: 3;
  432. overflow: hidden;
  433. text-overflow: ellipsis;
  434. }
  435. .sign-new-project-add {
  436. height: 176px;
  437. background: #ffffff;
  438. border-radius: 8px;
  439. border: 1px solid #ced3d9;
  440. display: flex;
  441. flex-direction: column;
  442. justify-content: center;
  443. align-items: center;
  444. cursor: pointer;
  445. }
  446. .sign-new-project-add-icon {
  447. width: 36px;
  448. }
  449. .sign-new-project-add-tips {
  450. margin-top: 16px;
  451. font-size: 16px;
  452. font-family: PingFangSC-Regular, PingFang SC;
  453. font-weight: 400;
  454. color: #0b121a;
  455. line-height: 22px;
  456. }
  457. .sign-new-works-list {
  458. margin-top: 18px;
  459. }
  460. .sign-new-project {
  461. padding-bottom: 30px;
  462. }
  463. </style>