adoptList.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <div class="adopt-list" :class="{ 'has-btn': isManySetting }">
  3. <div class="select-wrap common-select">
  4. <el-select class="select-item" v-model="areaVal" placeholder="全区" style="width: 116px">
  5. <el-option v-for="item in areaOptions" :key="item.value" :label="item.label" :value="item.value" />
  6. </el-select>
  7. <el-select class="select-item" v-model="typeVal" placeholder="全部品类" style="width: 116px">
  8. <el-option v-for="item in typeOptions" :key="item.value" :label="item.label" :value="item.value" />
  9. </el-select>
  10. <el-select class="select-item" v-model="ageVal" placeholder="树龄" style="width: 116px">
  11. <el-option v-for="item in ageOptions" :key="item.value" :label="item.label" :value="item.value" />
  12. </el-select>
  13. </div>
  14. <div class="select-wrap select-b common-select">
  15. <el-select class="select-item" v-model="allVal" placeholder="综合评分" style="width: 116px">
  16. <el-option v-for="item in allOptions" :key="item.value" :label="item.label" :value="item.value" />
  17. </el-select>
  18. <el-select class="select-item" v-model="ecologyVal" placeholder="生态评分" style="width: 116px">
  19. <el-option v-for="item in ecologyOptions" :key="item.value" :label="item.label" :value="item.value" />
  20. </el-select>
  21. <el-select class="select-item" v-model="statusVal" placeholder="全部状态" style="width: 116px">
  22. <el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value" />
  23. </el-select>
  24. </div>
  25. <div class="many-setting select-wrap" v-show="isManySetting">
  26. <el-select class="select-item many-select" v-model="settingType" placeholder="选中设置项" style="width: 96px">
  27. <template #label="{ label, value }">
  28. <span v-show="value!=='total'">设置</span>
  29. <span>{{ label }}</span>
  30. </template>
  31. <el-option v-for="(item, index) in settingTypeOptions" :key="index" :label="item.name" :value="item.value" />
  32. </el-select>
  33. <el-input-number
  34. style="width: 174px"
  35. placeholder="请输入"
  36. class="number-input"
  37. :controls="false"
  38. v-model="unifyPrice"
  39. :min="0"
  40. @change="setManyPrice"
  41. />
  42. <span class="unit">{{settingType === "price" ? "元/斤" : settingType === "age" ? "年" : "斤"}}</span>
  43. </div>
  44. <div class="list-wrap">
  45. <div class="list-item" v-for="(item, index) in displayedAdoptList" :key="index">
  46. <div class="list-info">
  47. <div class="tree-icon">
  48. <div class="tree-tag" v-show="item.status === 0">未守护</div>
  49. <div class="tree-tag wait" v-show="item.status === 1">已守护</div>
  50. <!-- <img class="tree-img" src="@/assets/images/foster-home/tree-item.png" alt="" /> -->
  51. <img class="tree-img" :src="require(`@/assets/images/foster-home/list/${index < 7 ? index : 0}.png`)" alt="" />
  52. <div class="tree-type-name-tag">白糖罂</div>
  53. </div>
  54. <div class="item-center">
  55. <div class="center-t">
  56. {{item.bm ? item.bm : "BTY-A3"+index}}
  57. <!-- <span class="type-tag">综合:{{item.zh||94}}分</span>
  58. <span class="type-tag">生态:{{item.st||92}}分</span> -->
  59. </div>
  60. <!-- 批量设置栽种时间 -->
  61. <div class="center-item" v-show="isManySetting && settingType !== 'price'">栽种时间:<span class="unit">{{item.time}}</span></div>
  62. <!-- 批量设置树龄或单项设置 -->
  63. <div class="center-item p-t-2 has-input" v-show="(isManySetting && settingType === 'age') || item.settingPrice">
  64. <span class="edit-label">树龄:</span>
  65. <el-input-number @change="settingSinglePrice" class="number-input" :controls="false" v-model="item.age" :min="0" />
  66. <span class="unit">年</span>
  67. </div>
  68. <!-- 不是编辑状态 -->
  69. <div class="center-item p-t-2 age-line" v-show="!isManySetting && !item.settingPrice">
  70. <div class="age-wrap">
  71. <div class="has-age">
  72. <div class="age">栽种时间:<span class="unit">{{ item.time }}</span></div>
  73. </div>
  74. <div class="sort-line"></div>
  75. </div>
  76. 树龄:<span class="unit"><span class="unit">{{item.age||12}}年</span></span>
  77. </div>
  78. <div class="center-item p-t-2 has-input" v-show="(isManySetting && settingType === 'price') || item.settingPrice">
  79. <span class="edit-label">单价:</span>
  80. <el-input-number @change="settingSinglePrice" class="number-input" :controls="false" v-model="item.price" :min="0" />
  81. <span class="unit">元/斤</span>
  82. </div>
  83. <div class="center-item" v-show="isManySetting && settingType !== 'age'">树龄:<span class="unit">{{item.age||5}}年</span></div>
  84. <div class="center-item" v-show="(isManySetting && settingType !== 'total')">栽种时间:<span class="unit">{{item.time}}</span></div>
  85. <div class="center-item p-t-2 has-input" v-show="(isManySetting && settingType === 'total') || item.settingPrice">
  86. <span class="edit-label">栽种时间:</span>
  87. <!-- <el-input-number @change="settingSinglePrice" class="number-input" :controls="false" v-model="item.total" :min="0" /> -->
  88. <el-date-picker
  89. v-model="item.time"
  90. type="date"
  91. format="YYYY.MM.DD"
  92. style="width: 140px"
  93. value-format="YYYY.MM.DD"
  94. placeholder="栽种时间"
  95. />
  96. </div>
  97. <div class="center-item p-t-2 user-wrap" v-show="item.status === 0 && !isManySetting && !item.settingPrice">
  98. <img src="@/assets/images/foster-home/user.png" alt="">
  99. 选择守护人
  100. </div>
  101. <div class="center-item p-t-2 progress-wrap" v-show="item.status === 1 && !isManySetting && !item.settingPrice">
  102. 守护人:
  103. <span class="unit">
  104. <div class="user-item">
  105. <div class="user-detail" v-for="(owner, oI) in owners" :key="oI">
  106. {{ owner.userName }}
  107. <span v-show="oI<owners.length-1">/</span>
  108. </div>
  109. </div>
  110. </span>
  111. </div>
  112. </div>
  113. <div v-show="!isManySetting && !item.settingPrice && ROLE == 1" @click="toSettingSinglePrice(index, true)">
  114. <img src="@/assets/images/common/edit-icon.png" alt="" />
  115. </div>
  116. </div>
  117. <div v-show="item.settingPrice" class="btn-group edit-one">
  118. <!-- 渐变主色按钮 -->
  119. <div class="btn cancel-btn" @click="toSettingSinglePrice(index, false)">取消</div>
  120. <div class="btn edit-btn" @click="toSettingSinglePrice(index, false)">确认修改</div>
  121. </div>
  122. </div>
  123. </div>
  124. <!-- 渐变主色按钮 -->
  125. <div class="center-btn" v-show="!isManySetting" @click="manySetPrice">批量定价</div>
  126. <!-- 渐变主色按钮 -->
  127. <div class="btn-group list-btn" v-show="isManySetting">
  128. <div class="btn cancel-btn" @click="saveManySetting(0)">取消</div>
  129. <div class="btn edit-btn" @click="saveManySetting(1)">保存</div>
  130. </div>
  131. </div>
  132. </template>
  133. <script setup>
  134. import { onMounted, ref } from "vue";
  135. import { useStore } from "vuex";
  136. let store = useStore();
  137. const ROLE = store.state.home.userRole;
  138. const areaVal = ref(0);
  139. const areaOptions = ref([
  140. { label: "全区", value: 0 },
  141. { label: "1区", value: 1 },
  142. { label: "2区", value: 2 },
  143. ]);
  144. const typeVal = ref(0);
  145. const typeOptions = ref([
  146. { label: "全部品类", value: 0 },
  147. { label: "白糖罂", value: 1 },
  148. { label: "井岗红糯", value: 2 },
  149. ]);
  150. const ageVal = ref(0);
  151. const ageOptions = ref([
  152. { label: "全部树龄", value: 0 },
  153. { label: "0-10年", value: 1 },
  154. { label: "10-20年", value: 2 },
  155. ]);
  156. const allVal = ref(0);
  157. const allOptions = ref([
  158. { label: "全部评分", value: 0 },
  159. { label: "0-10年", value: 1 },
  160. { label: "10-20年", value: 2 },
  161. ]);
  162. const ecologyVal = ref(0);
  163. const ecologyOptions = ref([
  164. { label: "生态评分", value: 0 },
  165. { label: "0-10年", value: 1 },
  166. { label: "10-20年", value: 2 },
  167. ]);
  168. const statusVal = ref(0);
  169. const statusOptions = ref([
  170. { label: "全部状态", value: 0 },
  171. { label: "0-10年", value: 1 },
  172. { label: "10-20年", value: 2 },
  173. ]);
  174. const adoptList = ref([
  175. { status: 0, price: 10, bm: "BTY-A21", pz: "白糖罂", zh: 94, st: 92, sl: 5, total: 215, time: "2022.02.15", },
  176. { status: 0, price: 12, bm: "BTY-A22", pz: "白糖罂", zh: 92, st: 94, sl: 6, total: 201, time: "2022.02.15" },
  177. { status: 0, price: 8, bm: "BTY-A25", pz: "白糖罂", zh: 92, st: 94, sl: 4, total: 220, time: "2022.02.15" },
  178. { status: 1, price: 13, bm: "BTY-A31", pz: "白糖罂", zh: 90, st: 92, sl: 6, total: 202, time: "2022.02.15" },
  179. { status: 1, price: 10, bm: "BTY-A33", pz: "白糖罂", zh: 90, st: 96, sl: 7, total: 190, time: "2022.02.15" },
  180. { status: 1, price: 16, time: "2022.02.15" },
  181. { status: 1, price: 16, time: "2022.02.15" },
  182. { status: 1, price: 16, time: "2022.02.15" },
  183. { status: 1, price: 16, time: "2022.02.15" },
  184. ]);
  185. const owners = ref([{userName: "王丽丽", value: 50}])
  186. const displayedAdoptList = ref([...adoptList.value]); // 初始时显示完整列表
  187. onMounted(() => {});
  188. // 批量定价
  189. const unifyPrice = ref(null);
  190. const isManySetting = ref(false);
  191. const settingTypeOptions = [
  192. {name: "树龄", value: "age"},
  193. {name: "品种", value: "price"},
  194. {name: "栽种时间", value: "total"},
  195. ]
  196. const settingType = ref("price")
  197. function manySetPrice() {
  198. isManySetting.value = true;
  199. displayedAdoptList.value = adoptList.value.filter((item) => item.status === 0);
  200. }
  201. function saveManySetting(isToSave) {
  202. isManySetting.value = false;
  203. displayedAdoptList.value = [...adoptList.value]; // 显示完整列表
  204. if (isToSave) {
  205. // 保存
  206. }
  207. }
  208. function setManyPrice(v) {
  209. displayedAdoptList.value.map(item => item.price = v)
  210. }
  211. // 设置单棵树单价
  212. function toSettingSinglePrice(i, val) {
  213. console.log('tototot');
  214. displayedAdoptList.value[i].settingPrice = val
  215. }
  216. function settingSinglePrice() {
  217. console.log('sss');
  218. }
  219. </script>
  220. <style lang="scss" scoped>
  221. .adopt-list {
  222. height: 100%;
  223. overflow: auto;
  224. // padding: 0 10px;
  225. &.has-btn {
  226. height: calc(100% - 60px);
  227. }
  228. .type-tag {
  229. color: #ffd489;
  230. background: rgba(255, 212, 137, 0.06);
  231. padding: 2px 4px;
  232. font-size: 10px;
  233. margin-left: 4px;
  234. border-radius: 4px;
  235. }
  236. .select-wrap {
  237. display: flex;
  238. align-items: center;
  239. padding: 0 10px;
  240. box-sizing: border-box;
  241. // ::v-deep {
  242. // .el-select__wrapper {
  243. // background: rgba(255, 212, 137, 0.06);
  244. // box-shadow: 0 0 0 1px rgba(255, 212, 137, 0.3) inset;
  245. // font-size: 13px;
  246. // .el-select__input {
  247. // color: #ffd489;
  248. // }
  249. // .el-select__placeholder {
  250. // color: #ffd489;
  251. // text-align: center;
  252. // }
  253. // .el-select__suffix {
  254. // color: #ffd489;
  255. // }
  256. // }
  257. // }
  258. .select-item + .select-item {
  259. margin-left: 5px;
  260. }
  261. }
  262. .select-b {
  263. margin-top: 8px;
  264. }
  265. .list-wrap {
  266. padding: 12px 0;
  267. .list-item {
  268. background: rgba(120, 120, 120, 0.05);
  269. padding: 8px 10px;
  270. border-radius: 5px;
  271. .list-info {
  272. display: flex;
  273. justify-content: space-between;
  274. align-items: center;
  275. }
  276. .edit-one {
  277. margin-top: 12px;
  278. border-top: 1px solid rgba(0, 0, 0, 0.2);
  279. &.btn-group {
  280. padding: 12px 0;
  281. .btn {
  282. flex: 1;
  283. text-align: center;
  284. padding: 5px;
  285. }
  286. }
  287. }
  288. .tree-icon {
  289. align-self: baseline;
  290. position: relative;
  291. .tree-tag {
  292. position: absolute;
  293. left: 0;
  294. top: 0;
  295. background: rgba(33, 153, 248, 0.7);
  296. border-radius: 5px 0 5px 0;
  297. color: #fff;
  298. padding: 1px 6px;
  299. font-size: 10px;
  300. &.wait {
  301. background: rgba(106, 106, 106, 0.7);
  302. }
  303. &.done {
  304. background: #757575;
  305. }
  306. }
  307. .tree-type-name-tag {
  308. position: absolute;
  309. left: 0;
  310. bottom: 0;
  311. background: rgba(0, 0, 0, 0.6);
  312. border-radius: 0 5px 5px 0;
  313. font-size: 10px;
  314. width: 100%;
  315. text-align: center;
  316. height: 18px;
  317. line-height: 18px;
  318. backdrop-filter: blur(4px);
  319. color: #fff;
  320. }
  321. .tree-img {
  322. width: 63px;
  323. height: 63px;
  324. border-radius: 5px;
  325. object-fit: cover;
  326. }
  327. }
  328. .item-center {
  329. flex: 1;
  330. padding: 0 12px;
  331. color: #000000;
  332. .center-t {
  333. font-size: 14px;
  334. }
  335. .center-item {
  336. color: #6c6c6c;
  337. font-size: 12px;
  338. padding-top: 2px;
  339. }
  340. .user-wrap {
  341. color: #F0AC37;
  342. }
  343. .progress-wrap {
  344. display: flex;
  345. align-items: center;
  346. .user-item {
  347. display: flex;
  348. align-items: center;
  349. }
  350. .progress-text {
  351. font-size: 12px;
  352. color: #999999;
  353. .over {
  354. color: #FFD489;
  355. }
  356. }
  357. ::v-deep {
  358. .el-progress-bar__outer {
  359. width: 100px;
  360. background: rgba(242, 243, 245, 0.23);
  361. }
  362. }
  363. }
  364. .age-line {
  365. display: flex;
  366. align-items: center;
  367. .age-wrap {
  368. display: flex;
  369. align-items: center;
  370. .sort-line {
  371. margin: 0 10px;
  372. height: 10px;
  373. width: 1px;
  374. background: rgba(0, 0, 0, 0.66);
  375. }
  376. }
  377. }
  378. .edit-label {
  379. display: inline-block;
  380. width: 76px;
  381. }
  382. .has-input {
  383. padding: 4px 0;
  384. .unit {
  385. padding-left: 5px;
  386. }
  387. }
  388. .small-btn-group {
  389. display: flex;
  390. font-size: 12px;
  391. }
  392. }
  393. }
  394. .list-item + .list-item {
  395. margin-top: 8px;
  396. }
  397. }
  398. .unit {
  399. padding-left: 5px;
  400. color: #000000;
  401. }
  402. .many-setting {
  403. background: rgba(255, 212, 137, 0.08);
  404. border: 1px solid rgba(255, 212, 137, 0.3);
  405. border-radius: 6px;
  406. color: #ffd489;
  407. padding: 12px 8px;
  408. margin-top: 12px;
  409. .many-select {
  410. ::v-deep {
  411. .el-select__wrapper {
  412. padding: 4px;
  413. box-shadow: none;
  414. }
  415. }
  416. }
  417. }
  418. .number-input {
  419. margin: 0 12px;
  420. ::v-deep {
  421. &.el-input-number {
  422. width: 80px;
  423. background: rgba(33, 153, 248, 0.08);
  424. border: 1px solid #2199F8;
  425. border-radius: 5px;
  426. }
  427. .el-input__wrapper {
  428. background: transparent;
  429. box-shadow: none;
  430. }
  431. .el-input-number.is-without-controls .el-input__wrapper {
  432. padding: 0 8px;
  433. }
  434. .el-input__inner {
  435. color: #2199F8;
  436. }
  437. }
  438. }
  439. .p-t-2 {
  440. padding-top: 2px;
  441. }
  442. .center-btn {
  443. position: absolute;
  444. bottom: 64px;
  445. left: 50%;
  446. transform: translateX(-50%);
  447. color: #FFFFFF;
  448. border-radius: 20px;
  449. font-size: 14px;
  450. padding: 7px 10px;
  451. cursor: pointer;
  452. border: 1px solid #fff;
  453. background: linear-gradient(180deg, #84C9FF, #2199F8);
  454. width: 194px;
  455. box-sizing: border-box;
  456. text-align: center;
  457. }
  458. .list-btn {
  459. position: absolute;
  460. bottom: 0;
  461. right: 0;
  462. }
  463. .btn-group {
  464. display: flex;
  465. align-items: center;
  466. justify-content: end;
  467. width: 100%;
  468. padding: 10px 12px;
  469. box-sizing: border-box;
  470. border-radius: 0 0 8px 8px;
  471. .btn {
  472. cursor: pointer;
  473. padding: 12px 36px;
  474. font-size: 14px;
  475. border-radius: 4px;
  476. border: 1px solid #2199F8;
  477. color: #2199F8;
  478. }
  479. .cancel-btn {
  480. color: #2199F8;
  481. }
  482. .edit-btn {
  483. background: #2199F8;
  484. color: #FFFFFF;
  485. }
  486. .btn + .btn {
  487. margin-left: 12px;
  488. }
  489. }
  490. }
  491. </style>