index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <div class="app-container">
  3. <el-form ref="form" :model="form" label-width="180px">
  4. <el-form-item label="每日自动同步:">
  5. <el-row>
  6. <el-col :span="20">
  7. <el-switch v-model="form.delivery" :disabled="form.cmo == ''" active-value="1" inactive-value="0" active-color="#169bd5" inactive-color="#8c8c8c" @change="changeEnable"></el-switch>
  8. </el-col>
  9. <el-col :span="4">
  10. <el-select v-model="form.cmo" placeholder="已对接公司" @change="change_company">
  11. <el-option v-for="(item,index) in companyArr" :key="index" :label="item.company" :value="item.company"/>
  12. </el-select>
  13. </el-col>
  14. </el-row>
  15. </el-form-item>
  16. <el-form-item label="同步内容:">
  17. 上传数据
  18. <el-radio-group v-model="form.type1" @change="changeEnable">
  19. <el-radio v-for="item in autoArr3" :disabled="form.cmo == ''" :key="item.id" :label="item.id" :value="item.name">{{ item.name }}</el-radio>
  20. </el-radio-group>
  21. <el-checkbox-group v-model="form.type2" @change="change_auto1('automatic','0',form.type2,myautoArr2)">
  22. <el-checkbox v-for="(item,index) in autoArr2" :key="index" :label="item.name" :value="item.name">{{ item.name }}</el-checkbox>
  23. </el-checkbox-group>
  24. </el-form-item>
  25. <el-divider></el-divider>
  26. <el-form-item label="手动同步:">
  27. <el-button class="successBorder" :disabled="form.cmo == ''" @click="handleSyncNow">立刻同步</el-button>
  28. <el-date-picker v-model="form.date" :clearable="false" :disabled="form.cmo == ''" style="margin-left: 10px;" type="date" placeholder="选择日期"> </el-date-picker>
  29. </el-form-item>
  30. <el-form-item label="同步内容:">
  31. 下载数据
  32. <el-checkbox-group v-model="form.type3" @change="change_auto1('manual','1',form.type3,myautoArr3)">
  33. <el-checkbox v-for="(item,index) in autoArr1" :key="index" :label="item.name" :value="item.name">{{ item.name }}</el-checkbox>
  34. </el-checkbox-group>
  35. 上传数据
  36. <el-checkbox-group v-model="form.type4" @change="change_auto1('manual','0',form.type4,myautoArr2)">
  37. <el-checkbox v-for="(item,index) in autoArr2" :key="item.index" :label="item.name" :value="item.name">{{ item.name }}</el-checkbox>
  38. </el-checkbox-group>
  39. </el-form-item>
  40. </el-form>
  41. </div>
  42. </template>
  43. <script>
  44. import { parseTime } from '@/utils/index.js'
  45. import { postJson,checkButtons } from '@/api/common'
  46. import Cookies from 'js-cookie'
  47. import Pagination from '@/components/Pagination'
  48. export default {
  49. name: 'DataSynchronization',
  50. components: { Pagination },
  51. data() {
  52. return {
  53. isRoleEdit: [],
  54. companyArr: [
  55. // { id: '公司1', name: '公司1' },
  56. // { id: '公司2', name: '公司2' },
  57. // { id: '公司3', name: '公司3' }
  58. ],
  59. autoArr1: [
  60. // { id: '栏舍', name: '栏舍' },
  61. // { id: '配方', name: '配方' },
  62. // { id: '饲料', name: '饲料' },
  63. // { id: '饲料分类', name: '饲料分类' },
  64. // { id: '牲畜类别', name: '牲畜类别' },
  65. // { id: '驾驶员', name: '驾驶员' }
  66. ],
  67. autoArr2: [
  68. // { id: '栏舍', name: '栏舍' },
  69. // { id: '配方', name: '配方' },
  70. // { id: '搅拌数据', name: '饲料' },
  71. // { id: '发料数据', name: '饲料分类' },
  72. // { id: '剩料数据', name: '牲畜类别' },
  73. // { id: '干物质信息', name: '干物质信息' },
  74. // { id: '滨州筛', name: '滨州筛' },
  75. // { id: '粪便筛', name: '粪便筛' },
  76. // { id: '计划完成车次', name: '计划完成车次' },
  77. // { id: '实际完成车次', name: '实际完成车次' },
  78. // { id: '计划重量', name: '计划重量' },
  79. // { id: '完成重量', name: '完成重量' },
  80. // { id: '准确率', name: '准确率' },
  81. ],
  82. myautoArr2:[],
  83. autoArr3: [
  84. { id: '0', name: '每车次结束' },
  85. { id: '1', name: '每班次结束' },
  86. { id: '2', name: '每天计划完成后' }
  87. ],
  88. time1:"",
  89. time2:"",
  90. time3:"",
  91. form: {
  92. cmo:'',
  93. name: '',
  94. region: '',
  95. date1: '',
  96. date2: '',
  97. delivery: '',
  98. type1: '',
  99. type2: [],
  100. type3: [],
  101. type4: [],
  102. resource: '',
  103. desc: '',
  104. date:parseTime(new Date(), '{y}-{m}-{d}')
  105. },
  106. table: {
  107. getdataListParm: {
  108. name: 'getPastureList',
  109. page: 1,
  110. offset: 1,
  111. pagecount: parseInt(Cookies.get('pageCount')),
  112. returntype: 'Map',
  113. parammaps: {
  114. 'pastureid': Cookies.get('pastureid'),
  115. 'phone': '',
  116. 'contact': '',
  117. 'address': '',
  118. 'pastureName': '',
  119. 'enable': ''
  120. }
  121. },
  122. tableKey: 0,
  123. list: [],
  124. total: 0,
  125. listLoading: true,
  126. temp: {}
  127. },
  128. requestParam: {},
  129. arrowDown: true,
  130. arrowUp: false,
  131. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  132. cellStyle: { padding: 0 + 'px' }
  133. }
  134. },
  135. created() {
  136. this.getCompanyList()
  137. this.getButtons()
  138. },
  139. mounted() {
  140. },
  141. methods: {
  142. getButtons() {
  143. const Edit = 'RanchInformation'
  144. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  145. this.isRoleEdit = isRoleEdit
  146. },
  147. onSubmit() {
  148. console.log('submit!');
  149. },
  150. handleEnableChange() {
  151. console.log('点击了是否启用')
  152. },
  153. handleConfirmStartChange() {
  154. console.log('点击了确认开始')
  155. },
  156. change_time1(){
  157. console.log(this.time1)
  158. },
  159. change_select(){
  160. console.log(this.time1)
  161. },
  162. getCompanyList(){
  163. const url = 'authdata/GetDataByName'
  164. const data = {}
  165. data.name = 'getCompanyName'
  166. postJson(url, data).then(response => {
  167. console.log('公司数据', response.data.list)
  168. if (response.data.list !== null) {
  169. this.companyArr = response.data.list
  170. } else {
  171. this.companyArr = []
  172. }
  173. })
  174. },
  175. change_company(item){
  176. console.log(item)
  177. this.getUploadCheckedList()
  178. this.getDownloadCheckedList()
  179. this.getUploadRadioCheckedList()
  180. },
  181. getUploadCheckedList(){
  182. const url = 'authdata/GetDataByName'
  183. const data = {}
  184. data.name = 'getScheduledUpByCompany'
  185. data.parammaps = {}
  186. data.parammaps.company = this.form.cmo
  187. postJson(url, data).then(response => {
  188. if (response.data.list !== null) {
  189. this.form.type2 = []
  190. this.autoArr2 = []
  191. this.myautoArr2 = []
  192. for(let i=0;i<response.data.list.length;i++){
  193. var obj={}
  194. obj.name = response.data.list[i].sname
  195. this.autoArr2.push(obj)
  196. this.myautoArr2.push(response.data.list[i])
  197. if(response.data.list[i].automatic== 1){
  198. this.form.type2.push(response.data.list[i].sname)
  199. }
  200. if(response.data.list[i].manual== 1){
  201. this.form.type4.push(response.data.list[i].sname)
  202. }
  203. }
  204. } else {
  205. this.companyArr = []
  206. }
  207. })
  208. },
  209. getDownloadCheckedList(){
  210. const url = 'authdata/GetDataByName'
  211. const data = {}
  212. data.name = 'getScheduledDownByCompany'
  213. data.parammaps = {}
  214. data.parammaps.company = this.form.cmo
  215. postJson(url, data).then(response => {
  216. if (response.data.list !== null) {
  217. this.form.type3 = []
  218. this.autoArr1 = []
  219. this.myautoArr3 = []
  220. for(let i=0;i<response.data.list.length;i++){
  221. var obj={}
  222. obj.name = response.data.list[i].sname
  223. this.autoArr1.push(obj)
  224. this.myautoArr3.push(response.data.list[i])
  225. if(response.data.list[i].manual== 1){
  226. this.form.type3.push(response.data.list[i].sname)
  227. }
  228. }
  229. console.log('this.form.type3',this.form.type3)
  230. console.log('this.autoArr1',this.autoArr1)
  231. } else {
  232. this.companyArr = []
  233. }
  234. })
  235. },
  236. getUploadRadioCheckedList(){
  237. const url = 'authdata/GetDataByName'
  238. const data = {}
  239. data.name = 'getScheduledUpStatusByCompany'
  240. data.parammaps = {}
  241. data.parammaps.company = this.form.cmo
  242. postJson(url, data).then(response => {
  243. if (response.data.list !== null) {
  244. this.form.type1 = response.data.list[0].times
  245. this.form.delivery = response.data.list[0].enable
  246. } else {
  247. this.form.type1 = ''
  248. this.form.delivery = ''
  249. }
  250. })
  251. },
  252. changeEnable(){
  253. const url = 'authdata/GetDataByName'
  254. const data = {}
  255. data.name = 'updateScheduledStatus'
  256. data.parammaps = {}
  257. data.parammaps.company = this.form.cmo
  258. data.parammaps.enable = this.form.delivery
  259. data.parammaps.times = this.form.type1
  260. postJson(url, data).then(response => {
  261. if (response.msg == 'ok') {
  262. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  263. } else {
  264. this.$notify({ title: '失败', message: '保存失败', type: 'success', duration: 2000 })
  265. }
  266. })
  267. },
  268. change_auto1(item,type,ids,list) {
  269. console.log(ids,'5555555555')
  270. // console.log(this.myautoArr2)
  271. var myIds = []
  272. for(let i=0;i<list.length;i++){
  273. for(let j=0;j<ids.length;j++){
  274. if(list[i].sname == ids[j]){
  275. myIds.push(list[i].scheduledid)
  276. }
  277. }
  278. }
  279. const url = 'authdata/scheduled/status/edit'
  280. const data = {}
  281. data.company = this.form.cmo
  282. data.id = myIds
  283. if(item == 'automatic'){
  284. data.automatic = '1'
  285. }else{
  286. data.manual = '1'
  287. }
  288. console.log('myIds',myIds)
  289. data.type = type
  290. postJson(url, data).then(response => {
  291. if (response.msg == 'ok') {
  292. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  293. } else {
  294. this.$notify({ title: '失败', message: '保存失败', type: 'success', duration: 2000 })
  295. }
  296. })
  297. },
  298. handleSyncNow() {
  299. const url = 'authdata/synchronizeNow'
  300. const data = {}
  301. data.company = this.form.cmo
  302. data.date = parseTime(this.form.date, '{y}-{m}-{d}')
  303. postJson(url, data).then(response => {
  304. if (response.msg == 'ok') {
  305. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  306. } else {
  307. this.$notify({ title: '失败', message: '保存失败', type: 'success', duration: 2000 })
  308. }
  309. })
  310. },
  311. }
  312. }
  313. </script>
  314. <style lang="scss" scoped>
  315. .search{margin-top:10px;}