| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- <template>
- <div style="cursor: default">
- <img style="width: 100%; margin: 0 0 0 -20px;" src="../../../../static/img/3.jpg" alt="" class="">
- </div>
- </template>
- <script>
- export default {
- data() {
- return {
- itemId: '',
- btnindex: '',
- page: 1,
- totalNum: null,
- base: '',
- pickcode: '',
- farmThingAddDialogVisible: false,
- farmThingEditDialogVisible: false,
- fieldsList: [],
- bases: [
- { value: '1', label: '基地一' },
- { value: '2', label: '基地二' },
- { value: '3', label: '基地三' },
- { value: '4', label: '基地四' }
- ],
- fields: [
- { value: '1', label: '地块一' },
- { value: '2', label: '地块二' },
- { value: '3', label: '地块三' },
- { value: '4', label: '地块四' }
- ],
- usefor: [
- { value: '1', label: '种植' },
- { value: '2', label: '种植' },
- { value: '3', label: '种植' },
- { value: '4', label: '种植' }
- ],
- addForm: {
- pro_name: '',
- batch_name: '', //批次名称
- pro_type: '',
- pro_cascader: []
- },
- editForm: {
- pro_name: '',
- batch_name: '', //批次名称
- pro_type: '',
- pro_cascader: []
- },
- addFormRules: {
- pro_name: [
- { required: true, message: '请填写产品名称', trigger: 'blur' }
- ],
- pro_type: [
- { required: true, message: '请填写产品类别', trigger: 'blur' }
- ],
- batch_name: [
- { required: true, message: '请填写批次名称', trigger: 'blur' }
- ],
- pro_cascader: [
- { required: true, message: '请选择地块', trigger: 'change' }
- ]
- },
- FieldCascader: []
- }
- },
- mounted() {
- this.getAllFieldsCascader()
- this.getplant()
- },
- methods: {
- getAllFieldsCascader() {
- this.$axios({
- method: 'POST',
- url: '/api/api_gateway?method=ascend.ascend_manage.all_base'
- }).then((res) => {
- if (res.data.message == '') {
- this.FieldCascader = res.data.data.data
- }
- })
- },
- getplant() {
- this.$axios({
- method: 'POST',
- url: '/api/api_gateway?method=ascend.ascend_manage.plant_info',
- data: this.qs.stringify({
- page: this.page,
- farmname: this.base,
- pickcode: this.pickcode
- })
- }).then((res) => {
- if (res.data.message == '') {
- this.totalNum = res.data.data.counts
- this.fieldsList = res.data.data.data
- }
- })
- },
- selChange(){
- this.page=1
- this.getplant()
- },
- plantAdd() {
- this.farmThingAddDialogVisible = true
- },
- plantEdit(item) {
- if (item.pickcode == '0') {
- //未采收
- this.editForm.pro_name = item.plantname
- this.editForm.batch_name = item.batch
- this.editForm.pro_type = item.planttype
- this.editForm.pro_cascader = [item.farm, item.land]
- this.itemId = item.id
- this.btnindex = 1
- this.farmThingEditDialogVisible = true
- } else {
- this.$message.warning('此地块已采收,禁止编辑!')
- }
- },
- plantDelet(id, backcode) {
- this.itemId = id
- this.btnindex = 2
- this.$confirm('确定要删除此作物么?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(() => {
- this.$axios({
- method: 'POST',
- url: '/api/api_gateway?method=ascend.ascend_manage.del_plant',
- data: this.qs.stringify({
- backcode: backcode
- })
- }).then((res) => {
- if (res.data.message == '') {
- this.$message({
- type: 'success',
- message: '删除成功!'
- })
- this.getplant()
- }
- })
- })
- .catch(() => {
- this.$message({
- type: 'info',
- message: '已取消删除'
- })
- })
- },
- AddDialogClosed() {
- this.$refs.addFormRef.resetFields()
- },
- EditDialogClosed() {
- this.$refs.editFormRef.resetFields()
- },
- addSubm() {
- this.$refs.addFormRef.validate((valid) => {
- if (!valid) return
- let farm = this.addForm.pro_cascader[0]
- let land = this.addForm.pro_cascader[1]
- this.$axios({
- method: 'POST',
- url: '/api/api_gateway?method=ascend.ascend_manage.add_plant',
- data: this.qs.stringify({
- farm: farm,
- land: land,
- planttype: this.addForm.pro_type,
- batch: this.addForm.batch_name,
- plantname: this.addForm.pro_name
- })
- }).then((res) => {
- if (res.data.message == '') {
- this.getplant()
- } else {
- this.$message.warning(res.data.message)
- }
- this.farmThingAddDialogVisible = false
- })
- })
- },
- editSubm() {
- this.$refs.editFormRef.validate((valid) => {
- if (!valid) return
- this.$axios({
- method: 'POST',
- url: '/api/api_gateway?method=ascend.ascend_manage.edit_plant',
- data: this.qs.stringify({
- id: this.itemId,
- planttype: this.editForm.pro_type,
- batch: this.editForm.batch_name,
- plantname: this.editForm.pro_name
- })
- }).then((res) => {
- if (res.data.message == '') {
- this.getplant()
- } else {
- this.$message.warning(res.data.message)
- }
- })
- this.farmThingEditDialogVisible = false
- })
- },
- changePage(val) {
- this.page = val
- this.getplant()
- }
- }
- }
- </script>
- <style lang='less' scoped>
- .search-box {
- display: flex;
- justify-content: space-between;
- margin-bottom: 10px;
- .el-input {
- width: 200px;
- }
- }
- .el-card {
- /deep/.el-card__body {
- position: relative;
- }
- .tag {
- position: absolute;
- top: 0;
- right: 20px;
- }
- text-align: center;
- color: #555;
- font-size: 13px;
- .borderLine {
- border: #eee;
- border-radius: 5px;
- -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
- padding: 8px 0;
- margin: 10px 0;
- }
- .btns {
- display: flex;
- width: 180px;
- border-radius: 30px;
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
- margin: 20px auto 0;
- a.bg {
- background: #17bb89;
- color: #fff;
- }
- a {
- width: 50%;
- height: 30px;
- line-height: 30px;
- cursor: pointer;
- &:first-child {
- border-top-left-radius: 30px;
- border-bottom-left-radius: 30px;
- }
- &:last-child {
- border-top-right-radius: 30px;
- border-bottom-right-radius: 30px;
- }
- }
- a:hover {
- background: #14a478;
- color: #fff;
- }
- }
- }
- .el-cascader {
- width: 100%;
- }
- </style>
|