adoptList.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  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: 88px">
  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. <div v-if="settingType === 'age'">
  34. <el-input-number
  35. style="width: 174px"
  36. placeholder="请输入"
  37. class="number-input-setting"
  38. :controls="false"
  39. v-model="batchAge"
  40. :min="0"
  41. @change="setManyPrice"
  42. />
  43. <span class="setting-unit">年</span>
  44. </div>
  45. <div v-if="settingType === 'price'">
  46. <el-input
  47. style="width: 190px"
  48. placeholder="请输入"
  49. class="number-input-setting"
  50. v-model="batchPrice"
  51. :min="0"
  52. @change="setManyPrice"
  53. />
  54. </div>
  55. <div v-if="settingType === 'total'" class="date-input">
  56. <el-date-picker
  57. v-model="batchTotal"
  58. type="date"
  59. format="YYYY-MM-DD"
  60. style="width: 190px"
  61. value-format="YYYY-MM-DD"
  62. placeholder="选择时间"
  63. />
  64. </div>
  65. </div>
  66. <div class="list-wrap">
  67. <div class="list-item" v-for="(item, index) in adoptList" :key="index">
  68. <div class="list-info">
  69. <div class="tree-icon">
  70. <div class="tree-tag" v-show="!item.offlineTakeSelected">未守护</div>
  71. <div class="tree-tag wait" v-show="item.offlineTakeSelected">已守护</div>
  72. <!-- <img class="tree-img" src="@/assets/images/foster-home/tree-item.png" alt="" /> -->
  73. <img class="tree-img" :src="item.icon || require(`@/assets/images/foster-home/list/1.png`)" alt="" />
  74. <div class="tree-type-name-tag">{{ item.pz }}</div>
  75. </div>
  76. <div class="item-center">
  77. <div class="center-t">
  78. {{item.fosterCode}}
  79. <!-- <span class="type-tag">综合:{{item.zh||94}}分</span>
  80. <span class="type-tag">生态:{{item.st||92}}分</span> -->
  81. </div>
  82. <!-- 批量设置树龄或单项设置 -->
  83. <div class="center-item p-t-2 has-input" v-show="(isManySetting && settingType === 'age') || item.settingPrice">
  84. <span class="edit-label">树龄:</span>
  85. <el-input-number @change="settingSinglePrice" class="number-input" :controls="false" v-model="item.age" :min="0" />
  86. <span class="unit">年</span>
  87. </div>
  88. <!-- 不是编辑状态 -->
  89. <div class="center-item p-t-2 age-line" v-show="!isManySetting && !item.settingPrice">
  90. <div class="age-wrap">
  91. <div class="has-age">
  92. <div class="age">栽种时间:<span class="unit">{{ item.time || '--' }}</span></div>
  93. </div>
  94. <div class="sort-line"></div>
  95. </div>
  96. 树龄:<span class="unit"><span class="unit">{{item.age||'--'}}年</span></span>
  97. </div>
  98. <div class="center-item" v-show="isManySetting && settingType !== 'age'"><span class="edit-label">树龄:</span><span class="unit">{{item.age||'--'}}年</span></div>
  99. <div class="center-item edit-item" v-show="isManySetting && settingType !== 'price'"><span class="edit-label">品种:</span><span class="unit">{{item.pz}}</span></div>
  100. <div class="center-item p-t-2 has-input edit-item" v-show="(isManySetting && settingType === 'price') || item.settingPrice">
  101. <span class="edit-label">品种:</span>
  102. <el-select v-model="item.pz" filterable style="width: 140px;" placeholder="请选择品种">
  103. <el-option v-for="(species, index) in speciesList" :key="index" :label="species.name" :value="species.name" />
  104. </el-select>
  105. <!-- <el-input @change="settingSinglePrice" style="width: 140px" class="number-input" v-model="item.pz" /> -->
  106. </div>
  107. <div class="center-item" v-show="(isManySetting && settingType !== 'total')"><span class="edit-label">栽种时间:</span><span class="unit">{{item.time}}</span></div>
  108. <div class="center-item p-t-2 has-input date-input" v-show="(isManySetting && settingType === 'total') || item.settingPrice">
  109. <span class="edit-label">栽种时间:</span>
  110. <!-- <el-input-number @change="settingSinglePrice" class="number-input" :controls="false" v-model="item.total" :min="0" /> -->
  111. <el-date-picker
  112. v-model="item.plantDate"
  113. type="date"
  114. format="YYYY-MM-DD"
  115. style="width: 140px"
  116. value-format="YYYY-MM-DD"
  117. placeholder="选择时间"
  118. />
  119. </div>
  120. <div class="center-item p-t-2 user-wrap" v-show="item.status === 0 && !isManySetting && !item.settingPrice">
  121. <img src="@/assets/images/foster-home/user.png" alt="">
  122. 选择守护人
  123. <el-select v-model="offlineTakeSelected" filterable style="width: 240px;" placeholder="请选择守护人">
  124. <el-option v-for="(user, index) in userList" :key="index" :label="user.name" :value="{value: user.tel, ...user}" />
  125. </el-select>
  126. </div>
  127. <div class="center-item p-t-2 progress-wrap" v-show="item.status === 1 && !isManySetting && !item.settingPrice">
  128. 守护人:
  129. <span class="unit">
  130. <div class="user-item">
  131. <div class="user-detail" v-for="(owner, oI) in owners" :key="oI">
  132. {{ owner.userName }}
  133. <span v-show="oI<owners.length-1">/</span>
  134. </div>
  135. </div>
  136. </span>
  137. </div>
  138. </div>
  139. <div v-show="!isManySetting && !item.settingPrice && ROLE == 1" @click="toSettingSinglePrice(index, true)">
  140. <img src="@/assets/images/common/edit-icon.png" alt="" />
  141. </div>
  142. </div>
  143. <div v-show="item.settingPrice" class="btn-group edit-one">
  144. <!-- 渐变主色按钮 -->
  145. <div class="btn cancel-btn" @click="toSettingSinglePrice(index, false)">取消</div>
  146. <div class="btn edit-btn" @click="toSettingSinglePrice(index, false, true)">确认修改</div>
  147. </div>
  148. </div>
  149. <div class="pagination-wrap">
  150. <el-pagination background :page-size="20" :pagerCount="5" v-model:current-page="currentPage" @current-change="getSamplePage" layout="prev, pager, next" :total="totalVal" />
  151. </div>
  152. </div>
  153. <!-- 渐变主色按钮 -->
  154. <div class="center-btn" v-show="!isManySetting" @click="manySetPrice">批量编辑果树</div>
  155. <!-- 渐变主色按钮 -->
  156. <div class="btn-group list-btn" v-show="isManySetting">
  157. <div class="btn cancel-btn" @click="saveManySetting(0)">取消</div>
  158. <div class="btn edit-btn" @click="saveManySetting(1)">保存</div>
  159. </div>
  160. </div>
  161. </template>
  162. <script setup>
  163. import { ElMessage } from "element-plus";
  164. import { onMounted, ref } from "vue";
  165. import { useStore } from "vuex";
  166. let store = useStore();
  167. const ROLE = store.state.home.userRole;
  168. const areaVal = ref(0);
  169. const areaOptions = ref([
  170. { label: "全区", value: 0 },
  171. { label: "1区", value: 1 },
  172. { label: "2区", value: 2 },
  173. ]);
  174. const typeVal = ref(0);
  175. const typeOptions = ref([
  176. { label: "全部品类", value: 0 },
  177. { label: "白糖罂", value: 1 },
  178. { label: "井岗红糯", value: 2 },
  179. ]);
  180. const ageVal = ref(0);
  181. const ageOptions = ref([
  182. { label: "全部树龄", value: 0 },
  183. { label: "0-10年", value: 1 },
  184. { label: "10-20年", value: 2 },
  185. ]);
  186. const allVal = ref(0);
  187. const allOptions = ref([
  188. { label: "全部评分", value: 0 },
  189. { label: "0-10年", value: 1 },
  190. { label: "10-20年", value: 2 },
  191. ]);
  192. const ecologyVal = ref(0);
  193. const ecologyOptions = ref([
  194. { label: "生态评分", value: 0 },
  195. { label: "0-10年", value: 1 },
  196. { label: "10-20年", value: 2 },
  197. ]);
  198. const statusVal = ref(0);
  199. const statusOptions = ref([
  200. { label: "全部状态", value: 0 },
  201. { label: "0-10年", value: 1 },
  202. { label: "10-20年", value: 2 },
  203. ]);
  204. const adoptList = ref([]);
  205. const owners = ref([{userName: "王丽丽", value: 50}])
  206. const offlineTakeSelected = ref(null)
  207. const userList = ref([])
  208. const speciesList = ref([])
  209. function getUserList() {
  210. VE_API.manage_interface.offlineTakeList({farmId: 766}).then(({data}) => {
  211. userList.value = data
  212. })
  213. VE_API.manage_interface.speciesList({farmId: 766}).then(({data}) => {
  214. speciesList.value = data
  215. })
  216. }
  217. onMounted(() => {
  218. getSamplePage()
  219. getUserList()
  220. });
  221. const currentPage = ref(1)
  222. const totalVal = ref(0)
  223. function getSamplePage() {
  224. VE_API.manage_interface.fetchSamplePage({farmId: 80865, page: currentPage.value, limit: 20}).then(({data, count}) => {
  225. adoptList.value = data
  226. totalVal.value = count
  227. })
  228. }
  229. // 批量设置
  230. const batchAge = ref(null);
  231. const batchPrice = ref(null);
  232. const batchTotal = ref(null);
  233. const isManySetting = ref(false);
  234. const settingTypeOptions = [
  235. {name: "树龄", value: "age"},
  236. {name: "品种", value: "price"},
  237. {name: "栽种时间", value: "total"},
  238. ]
  239. const settingType = ref("age")
  240. function manySetPrice() {
  241. isManySetting.value = true;
  242. }
  243. function saveManySetting(isToSave) {
  244. isManySetting.value = false;
  245. if (isToSave) {
  246. // 保存
  247. }
  248. }
  249. function setManyPrice(v) {
  250. // adoptList.value.map(item => item.price = v)
  251. }
  252. // 设置单棵树单价
  253. function toSettingSinglePrice(i, val, toSave = false) {
  254. console.log('tototot');
  255. const data = adoptList.value[i]
  256. if (toSave) {
  257. const params = {
  258. sampleId: data.sampleId,
  259. pz: data.pz,
  260. age: data.age,
  261. plantDate: data.plantDate,
  262. offlineTakeSelected: {...offlineTakeSelected.value}
  263. }
  264. VE_API.manage_interface.editFosterSample(params).then((res) => {
  265. if (res.code === 0) {
  266. ElMessage.success("修改成功")
  267. adoptList.value[i].settingPrice = val
  268. }
  269. })
  270. } else {
  271. adoptList.value[i].settingPrice = val
  272. }
  273. }
  274. function settingSinglePrice() {
  275. console.log('sss');
  276. }
  277. </script>
  278. <style lang="scss" scoped>
  279. .adopt-list {
  280. height: 100%;
  281. overflow: auto;
  282. // padding: 0 10px;
  283. &.has-btn {
  284. height: calc(100% - 60px);
  285. }
  286. .type-tag {
  287. color: #ffd489;
  288. background: rgba(255, 212, 137, 0.06);
  289. padding: 2px 4px;
  290. font-size: 10px;
  291. margin-left: 4px;
  292. border-radius: 4px;
  293. }
  294. .select-wrap {
  295. display: flex;
  296. align-items: center;
  297. padding: 0 10px;
  298. box-sizing: border-box;
  299. // ::v-deep {
  300. // .el-select__wrapper {
  301. // background: rgba(255, 212, 137, 0.06);
  302. // box-shadow: 0 0 0 1px rgba(255, 212, 137, 0.3) inset;
  303. // font-size: 13px;
  304. // .el-select__input {
  305. // color: #ffd489;
  306. // }
  307. // .el-select__placeholder {
  308. // color: #ffd489;
  309. // text-align: center;
  310. // }
  311. // .el-select__suffix {
  312. // color: #ffd489;
  313. // }
  314. // }
  315. // }
  316. .select-item + .select-item {
  317. margin-left: 5px;
  318. }
  319. }
  320. .select-b {
  321. margin-top: 8px;
  322. }
  323. .pagination-wrap {
  324. position: absolute;
  325. bottom: 0;
  326. width: 100%;
  327. text-align: right;
  328. right: 0;
  329. background: #fff;
  330. padding: 12px;
  331. box-shadow: 0px 0px 4px #ccc;
  332. box-sizing: border-box;
  333. ::v-deep {
  334. .el-pagination {
  335. justify-content: center;
  336. }
  337. }
  338. }
  339. .list-wrap {
  340. padding: 12px 0;
  341. margin-bottom: 60px;
  342. .list-item {
  343. background: rgba(120, 120, 120, 0.05);
  344. padding: 8px 16px 8px 10px;
  345. border-radius: 5px;
  346. .list-info {
  347. display: flex;
  348. justify-content: space-between;
  349. align-items: center;
  350. }
  351. .edit-one {
  352. margin-top: 12px;
  353. border-top: 1px solid rgba(0, 0, 0, 0.2);
  354. &.btn-group {
  355. padding: 12px 0;
  356. .btn {
  357. flex: 1;
  358. text-align: center;
  359. padding: 5px;
  360. }
  361. }
  362. }
  363. .tree-icon {
  364. align-self: baseline;
  365. position: relative;
  366. .tree-tag {
  367. position: absolute;
  368. left: 0;
  369. top: 0;
  370. background: rgba(33, 153, 248, 0.7);
  371. border-radius: 5px 0 5px 0;
  372. color: #fff;
  373. padding: 1px 6px;
  374. font-size: 10px;
  375. &.wait {
  376. background: rgba(106, 106, 106, 0.7);
  377. }
  378. &.done {
  379. background: #757575;
  380. }
  381. }
  382. .tree-type-name-tag {
  383. position: absolute;
  384. left: 0;
  385. bottom: 0;
  386. background: rgba(0, 0, 0, 0.6);
  387. border-radius: 0 5px 5px 0;
  388. font-size: 10px;
  389. width: 100%;
  390. text-align: center;
  391. height: 18px;
  392. line-height: 18px;
  393. backdrop-filter: blur(4px);
  394. color: #fff;
  395. }
  396. .tree-img {
  397. width: 63px;
  398. height: 63px;
  399. border-radius: 5px;
  400. object-fit: cover;
  401. }
  402. }
  403. .item-center {
  404. flex: 1;
  405. padding: 0 12px;
  406. color: #000000;
  407. .center-t {
  408. font-size: 14px;
  409. }
  410. .center-item {
  411. color: #6c6c6c;
  412. font-size: 12px;
  413. padding-top: 2px;
  414. }
  415. .edit-item {
  416. padding: 6px 0;
  417. }
  418. .user-wrap {
  419. color: #F0AC37;
  420. }
  421. .progress-wrap {
  422. display: flex;
  423. align-items: center;
  424. .user-item {
  425. display: flex;
  426. align-items: center;
  427. }
  428. .progress-text {
  429. font-size: 12px;
  430. color: #999999;
  431. .over {
  432. color: #FFD489;
  433. }
  434. }
  435. ::v-deep {
  436. .el-progress-bar__outer {
  437. width: 100px;
  438. background: rgba(242, 243, 245, 0.23);
  439. }
  440. }
  441. }
  442. .age-line {
  443. display: flex;
  444. align-items: center;
  445. .age-wrap {
  446. display: flex;
  447. align-items: center;
  448. .sort-line {
  449. margin: 0 10px;
  450. height: 10px;
  451. width: 1px;
  452. background: rgba(0, 0, 0, 0.66);
  453. }
  454. }
  455. }
  456. .edit-label {
  457. display: inline-block;
  458. width: 76px;
  459. }
  460. .has-input {
  461. padding: 4px 0;
  462. .unit {
  463. padding-left: 5px;
  464. }
  465. &.edit-item {
  466. padding: 6px 0;
  467. }
  468. }
  469. .small-btn-group {
  470. display: flex;
  471. font-size: 12px;
  472. }
  473. }
  474. }
  475. .list-item + .list-item {
  476. margin-top: 8px;
  477. }
  478. }
  479. .unit {
  480. padding-left: 5px;
  481. color: #000000;
  482. }
  483. .many-setting {
  484. background: rgba(33, 153, 248, 0.1);
  485. border: 1px solid #2199F8;
  486. border-radius: 5px;
  487. color: #2199F8;
  488. padding: 12px 8px;
  489. margin: 12px 8px 0 12px;
  490. color: #0064B3;
  491. ::v-deep {
  492. .many-select {
  493. margin-right: 10px;
  494. .el-select__wrapper {
  495. padding: 4px;
  496. box-shadow: none;
  497. background: none;
  498. }
  499. .el-select__placeholder, .el-select__caret {
  500. color: #0064B3;
  501. }
  502. }
  503. .number-input-setting {
  504. .el-input__wrapper {
  505. box-shadow: 0 0 0 1px #2199F8 inset;
  506. border-radius: 6px;
  507. }
  508. .el-input__inner, .el-input__inner::placeholder {
  509. color: #2199F8;
  510. text-align: center;
  511. }
  512. }
  513. }
  514. .setting-unit {
  515. padding-left: 10px;
  516. }
  517. }
  518. .number-input {
  519. // margin: 0 12px;
  520. ::v-deep {
  521. &.el-input-number, &.el-input {
  522. width: 90px;
  523. background: rgba(33, 153, 248, 0.08);
  524. border: 1px solid #2199F8;
  525. border-radius: 5px;
  526. }
  527. .el-input__wrapper {
  528. background: transparent;
  529. box-shadow: none;
  530. }
  531. .el-input-number.is-without-controls .el-input__wrapper {
  532. padding: 0 8px;
  533. }
  534. .el-input__inner, .el-input__inner::placeholder {
  535. color: #2199F8;
  536. text-align: center;
  537. }
  538. }
  539. }
  540. .date-input {
  541. ::v-deep {
  542. .el-date-editor {
  543. .el-input__wrapper {
  544. background: rgba(33, 153, 248, 0.08);
  545. box-shadow: 0 0 0 1px #2199F8 inset;
  546. }
  547. .el-input__inner, .el-input__inner::placeholder {
  548. color: #2199F8;
  549. }
  550. .el-input__prefix {
  551. color: #2199F8;
  552. }
  553. }
  554. }
  555. }
  556. .p-t-2 {
  557. padding-top: 2px;
  558. }
  559. .center-btn {
  560. position: absolute;
  561. bottom: 64px;
  562. left: 50%;
  563. transform: translateX(-50%);
  564. color: #FFFFFF;
  565. border-radius: 20px;
  566. font-size: 14px;
  567. padding: 7px 10px;
  568. cursor: pointer;
  569. border: 1px solid #fff;
  570. background: linear-gradient(180deg, #84C9FF, #2199F8);
  571. width: 194px;
  572. box-sizing: border-box;
  573. text-align: center;
  574. }
  575. .list-btn {
  576. position: absolute;
  577. bottom: 0;
  578. right: 0;
  579. }
  580. .btn-group {
  581. display: flex;
  582. align-items: center;
  583. justify-content: end;
  584. width: 100%;
  585. padding: 10px 12px;
  586. box-sizing: border-box;
  587. border-radius: 0 0 8px 8px;
  588. .btn {
  589. cursor: pointer;
  590. padding: 12px 36px;
  591. font-size: 14px;
  592. border-radius: 4px;
  593. border: 1px solid #2199F8;
  594. color: #2199F8;
  595. }
  596. .cancel-btn {
  597. color: #2199F8;
  598. }
  599. .edit-btn {
  600. background: #2199F8;
  601. color: #FFFFFF;
  602. }
  603. .btn + .btn {
  604. margin-left: 12px;
  605. }
  606. }
  607. }
  608. </style>