index.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-input v-model="table.getdataListParm.parammaps.bname" placeholder="栏舍名称" style="width: 180px;" class="filter-item" clearable />
  5. <el-input v-model="table.getdataListParm.parammaps.bcode" placeholder="栏舍编号" style="width: 180px;" class="filter-item" clearable />
  6. <el-select v-model="table.getdataListParm.parammaps.enable" filterable :placeholder="$t('formulationEvaluation.sfqy')" class="filter-item" style="width: 120px;" clearable>
  7. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  8. </el-select>
  9. <div ref="selectInput" class="filter-item selectInput">
  10. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  11. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  12. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  13. <ul v-if="arrowUp" class="selectUl">
  14. <li><a>允许误差数</a><el-input v-model="table.getdataListParm.parammaps.allowratio" type="text" style="width: 245px;" /></li>
  15. <li><a>跳转重量域</a><el-input v-model="table.getdataListParm.parammaps.autozone" type="text" style="width: 245px;" /></li>
  16. <li>
  17. <a>跳转延时</a>
  18. <el-select v-model="table.getdataListParm.parammaps.autosecond" filterable class="filter-item" style="width: 245px;" clearable>
  19. <el-option v-for="item in jumpDelayList" :key="item.value" :label="item.label" :value="item.value" />
  20. </el-select>
  21. </li>
  22. <li>
  23. <div style="float: right;">
  24. <el-button class="downminCancel" @click="arrowUp=false;arrowDown=true;">{{$t('formulationEvaluation.cancel')}}</el-button>
  25. <el-button class="miniPrimary" @click="form_search">{{$t('formulationEvaluation.search')}}</el-button>
  26. </div>
  27. </li>
  28. </ul>
  29. </div>
  30. <el-button class="successBorder" @click="form_search">{{$t('common.query')}}</el-button>
  31. <el-button class="successBorder" @click="handleRefresh">{{$t('common.reset')}}</el-button>
  32. </div>
  33. <div class="operation">
  34. <el-button v-if="isRoleEdit" style="float:left;" class="success" icon="el-icon-plus" @click="handleCreate">{{$t('formulationEvaluation.add')}}</el-button>
  35. <el-button v-if="isRoleEdit" style="float:left;" class="danger" icon="el-icon-delete" @click="form_delete">{{$t('formulationEvaluation.del')}}</el-button>
  36. <el-button v-if="isOrder && isRoleEdit" style="float:left;" icon="el-icon-sort" class="success" @click="handleChangeOrder">{{$t('formulationEvaluation.ggsx')}}</el-button>
  37. <div v-else style="float:left;margin-left: 10px;">
  38. <el-button v-if="isRoleEdit" icon="el-icon-folder-checked" class="success" @click="saveChangeOrder">{{$t('formulationEvaluation.save')}}</el-button>
  39. <el-button v-if="isRoleEdit" icon="el-icon-close" class="sortCancel" @click="cancelChangeOrder">{{$t('formulationEvaluation.cancel')}}</el-button>
  40. </div>
  41. <el-button v-if="isRoleEdit && sapUpload.isSap" class="success" icon="el-icon-plus" @click="handleGetSapCode">获取SAP编码</el-button>
  42. <el-button v-if="isRoleEdit && ispalyUd" class="success" icon="el-icon-plus" @click="handleGetUd">获取UD栏舍</el-button>
  43. </div>
  44. <div class="table">
  45. <u-table
  46. id="table"
  47. :key="table.tableKey"
  48. ref="table"
  49. v-loading="table.listLoading"
  50. element-loading-text="给我一点时间"
  51. :data="table.list"
  52. border
  53. fit
  54. highlight-current-row
  55. style="width: 100%;"
  56. :row-style="rowStyle"
  57. :cell-style="cellStyle"
  58. class="elTable table-fixed"
  59. row-key="id"
  60. @selection-change="handleSelectionChange"
  61. :max-height="myHeight"
  62. >
  63. <el-table-column type="selection" align="center" width="50" />
  64. <el-table-column :label="$t('formulationEvaluation.xh')" type="index" align="center" width="50" />
  65. <el-table-column :label="$t('errorAnalysis.isHouseName')" min-width="130px" align="center">
  66. <template slot-scope="scope">
  67. <span v-if="scope.row.NoEdit">{{ scope.row.bname }}</span>
  68. <el-input v-if="scope.row.Edit" v-model="scope.row.bname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:95%;padding:10px 0;" maxlength="32" />
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="栏舍编号" min-width="130px" align="center">
  72. <template slot-scope="scope">
  73. <span v-if="scope.row.NoEdit">{{ scope.row.bcode }}</span>
  74. <el-input v-if="scope.row.Edit" v-model="scope.row.bcode" placeholder="1-32个字符" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="允许误差数(kg)" min-width="150px" align="center">
  78. <template slot-scope="scope">
  79. <span v-if="scope.row.NoEdit">{{ scope.row.allowratio }}</span>
  80. <el-input v-if="scope.row.Edit" v-model="scope.row.allowratio" style="width:95%;padding:10px 0;" />
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="跳转重量域(kg)" min-width="150px" align="center">
  84. <template slot-scope="scope">
  85. <span v-if="scope.row.NoEdit">{{ scope.row.autozone }}</span>
  86. <el-input v-if="scope.row.Edit" v-model="scope.row.autozone" :disabled="scope.row.autosecond=='0'" style="width:95%;padding:10px 0;" />
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="跳转延时(s)" min-width="150px" align="center">
  90. <template slot-scope="scope">
  91. <span v-if="scope.row.NoEdit">{{ scope.row.autosecondname }}</span>
  92. <el-select v-if="scope.row.Edit" v-model="scope.row.autosecond" filterable class="filter-item" style="width: 95%;padding:10px 0;" @change="changeAutosecond">
  93. <el-option v-for="item in jumpDelayList" :key="item.value" :label="item.label" :value="item.value" />
  94. <!-- <el-option v-for="item in jumpDelayList" :key="item.label" :label="item.label" :value="item.label" /> -->
  95. </el-select>
  96. </template>
  97. </el-table-column>
  98. <el-table-column :label="$t('errorAnalysis.pen')" min-width="150px" align="center">
  99. <template slot-scope="scope">
  100. <span v-if="scope.row.NoEdit">{{ scope.row.KTEXT }}</span>
  101. <el-select v-if="scope.row.Edit" v-model="scope.row.AUFNR" filterable class="filter-item" style="width: 95%;padding:10px 0;">
  102. <el-option v-for="item in cattleorderList" :key="item.AUFNR" :label="item.KTEXT" :value="item.AUFNR" />
  103. </el-select>
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="确认开始" min-width="110px" align="center">
  107. <template slot-scope="scope">
  108. <el-switch v-model="scope.row.isstart" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleConfirmStartChange(scope.$index, scope.row)" />
  109. </template>
  110. </el-table-column>
  111. <el-table-column :label="$t('formulationEvaluation.sfqy')" min-width="110px" align="center">
  112. <template slot-scope="scope">
  113. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="ud编码" min-width="110px" align="center">
  117. <template slot-scope="scope">
  118. <span>{{scope.row.udcode}}</span>
  119. </template>
  120. </el-table-column>
  121. <el-table-column label="ud名称" min-width="110px" align="center">
  122. <template slot-scope="scope">
  123. <span>{{scope.row.udname}}</span>
  124. </template>
  125. </el-table-column>
  126. <el-table-column :label="$t('errorAnalysis.cz')" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
  127. <template slot-scope="{row}">
  128. <!-- 新增 -->
  129. <el-button v-if="row.isCreate" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="createData(row)" />
  130. <span v-if="row.isCreate" class="centerSpan">|</span>
  131. <el-button v-if="row.isCreate" class="minCancel" icon="el-icon-close" @click="createCancel(row)" />
  132. <!-- 编辑 -->
  133. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  134. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  135. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" />
  136. <!-- 编辑保存 -->
  137. <el-button v-if="row.isUpdateSave" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData(row)" />
  138. <span v-if="row.isUpdateSave" class="centerSpan">|</span>
  139. <el-button v-if="row.isUpdateSave" class="minCancel" icon="el-icon-close" @click="updateCancel(row)" />
  140. </template>
  141. </el-table-column>
  142. </u-table>
  143. <span v-if="table.listLoading == false" style="margin-right: 30px;margin-top: 10px;font-size: 14px;">{{$t('processAnalysis.total')}}{{ table.total }}{{$t('processAnalysis.tiao')}}</span>
  144. <!-- <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" /> -->
  145. </div>
  146. <!-- 获取SAP编码 -->
  147. <el-dialog :fullscreen="dialogFull" :visible.sync="sapCode2.dialogFormVisible" :close-on-click-modal="false" width="50%">
  148. <template slot="title">
  149. <div class="avue-crud__dialog__header">
  150. <span class="el-dialog__title">
  151. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  152. {{ textMap[sapCode2.dialogStatus] }}
  153. </span>
  154. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  155. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  156. <svg-icon v-else icon-class="fullscreen" />
  157. </div>
  158. </div>
  159. </template>
  160. <div class="app-add">
  161. <el-form ref="sapCode2" :rules="sapCode2.rules" :model="sapCode2.temp" label-position="right" label-width="155px" style="width: 100%;margin:0 auto 50px">
  162. <el-row>
  163. <el-col :span="18">
  164. <el-form-item :label="$t('dailyExecutionPlan.sjfw')" prop="inputDatetime">
  165. <el-date-picker v-model="sapCode2.temp.inputDatetime" class="inputDatetime filter-item" type="daterange" :range-separator="$t('common.to')" :start-placeholder="$t('common.startTime')" :end-placeholder="$t('common.endTime')" style="width: 100%;" :clearable="false" />
  166. </el-form-item>
  167. </el-col>
  168. </el-row>
  169. </el-form>
  170. <div slot="footer" class="dialog-footer">
  171. <el-button class="cancelClose" @click="sapCode2.dialogFormVisible = false;getList()">{{$t('common.closed')}}</el-button>
  172. <el-button v-if="sapCode2.dialogStatus==='sapCode2' && isRoleEdit" class="save" :disabled="isokDisable" @click="sapCodeData2()">{{$t('errorAnalysis.confirm')}}</el-button>
  173. </div>
  174. </div>
  175. </el-dialog>
  176. </div>
  177. </template>
  178. <script>
  179. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig, checkButtons,postJson } from '@/api/common'
  180. import Cookies from 'js-cookie'
  181. import draggable from 'vuedraggable'
  182. import Sortable from 'sortablejs'
  183. import { parseTime } from '@/utils/index.js'
  184. import Pagination from '@/components/Pagination'
  185. import { MessageBox } from 'element-ui'
  186. export default {
  187. name: 'GroupColumn',
  188. components: { Pagination,draggable },
  189. data() {
  190. return {
  191. dialogFull: false,
  192. isRoleEdit: [],
  193. requestParams: [
  194. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['跳转延时'] },
  195. { name: 'getBarClass', offset: 0, pagecount: 0, parammaps: {pastureid: Cookies.get('pastureid')} },
  196. { name: 'getScopeherd', offset: 0, pagecount: 0, parammaps: {pastureid: Cookies.get('pastureid')} },
  197. { name: 'getCattleorder', offset: 0, pagecount: 0, parammaps: {pastureid: Cookies.get('pastureid')} }
  198. ],
  199. enableList: [{ id: '1', name: '是' }, { id: '0', name: '否' }],
  200. jumpDelayList: [],
  201. barClassList:[],
  202. scopeherdList:[],
  203. cattleorderList:[],
  204. table: {
  205. getdataListParm: {
  206. name: 'getBarList',
  207. page: 1,
  208. offset: 1,
  209. pagecount: '',
  210. returntype: 'Map',
  211. parammaps: {
  212. pastureid: Cookies.get('pastureid'),
  213. bcode: '',
  214. bname: '',
  215. allowratio: '',
  216. autozone: '',
  217. autosecond: '',
  218. enable: ''
  219. }
  220. },
  221. tableKey: 0,
  222. list: [],
  223. total: 0,
  224. listLoading: true,
  225. temp: {}
  226. },
  227. sapCode2:{
  228. dialogFormVisible: false,
  229. dialogStatus: '',
  230. materialtypeList:[],
  231. temp:{
  232. inputDatetime: [parseTime(new Date(), '{y}-{m}-{d}'), parseTime(new Date(), '{y}-{m}-{d}')],
  233. sapMaterialtype:'',
  234. },
  235. rules: {
  236. inputDatetime :[{required: true, message: '必填', trigger: 'blur' }]
  237. }
  238. },
  239. textMap: {
  240. sapCode2: '获取SAP编码',
  241. },
  242. sapUpload:{
  243. getdataListParm: {
  244. name: 'getSysoptEnable',
  245. page: 1,
  246. offset: 1,
  247. pagecount: 1,
  248. returntype: 'Map',
  249. parammaps: {
  250. pastureid: Cookies.get('pastureid'),
  251. inforname: 'xdmyBarSync'
  252. }
  253. },
  254. isSap: false
  255. },
  256. requestParam: {},
  257. isokDisable: false,
  258. selectList: [],
  259. arrowDown: true,
  260. arrowUp: false,
  261. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  262. cellStyle: { padding: 0 + 'px' },
  263. dropState: false,
  264. isOrder: true,
  265. ispalyUd: true,
  266. myHeight:document.documentElement.clientHeight - 85- 150
  267. }
  268. },
  269. created() {
  270. this.getIspalyUd()
  271. this.getList()
  272. this.getDownList()
  273. this.getButtons()
  274. this.getIsSap()
  275. },
  276. mounted() {
  277. document.addEventListener('click', (e) => {
  278. if (this.$refs.selectInput !== undefined) {
  279. if (!this.$refs.selectInput.contains(e.target)) {
  280. this.arrowDown = true
  281. this.arrowUp = false
  282. } else {
  283. this.arrowDown = false
  284. this.arrowUp = true
  285. }
  286. }
  287. })
  288. },
  289. methods: {
  290. getIsSap() {
  291. GetDataByName(this.sapUpload.getdataListParm).then(response => {
  292. // console.log()
  293. if(response.data.list !== null){
  294. if(response.data.list[0].inforvalue == 1){
  295. this.sapUpload.isSap = true
  296. }else{
  297. this.sapUpload.isSap = false
  298. }
  299. console.log(this.sapUpload.isSap)
  300. }
  301. })
  302. },
  303. getButtons() {
  304. const Edit = 'GroupColumn'
  305. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  306. console.log(isRoleEdit,'hss------')
  307. this.isRoleEdit = isRoleEdit
  308. },
  309. getDownList() {
  310. GetDataByNames(this.requestParams).then(response => {
  311. this.jumpDelayList = response.data.getDictByName.list
  312. this.barClassList = response.data.getBarClass.list
  313. this.scopeherdList = response.data.getScopeherd.list
  314. this.cattleorderList = response.data.getCattleorder.list
  315. })
  316. },
  317. getList() {
  318. this.table.listLoading = true
  319. GetDataByName(this.table.getdataListParm).then(response => {
  320. console.log('table数据', response.data.list)
  321. if (response.data.list !== null) {
  322. for (let i = 0; i < response.data.list.length; i++) {
  323. this.$set(response.data.list[i], 'Edit', false) // 编辑
  324. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  325. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  326. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  327. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  328. }
  329. this.table.list = response.data.list
  330. this.table.pageNum = response.data.pageNum
  331. this.table.pageSize = response.data.pageSize
  332. } else {
  333. this.table.list = []
  334. }
  335. this.table.total = response.data.total
  336. setTimeout(() => {
  337. this.table.listLoading = false
  338. }, 100)
  339. })
  340. },
  341. handleEnableChange() {
  342. console.log('点击了是否启用')
  343. },
  344. handleConfirmStartChange() {
  345. console.log('点击了确认开始')
  346. },
  347. form_search() {
  348. console.log('点击了查询')
  349. this.table.getdataListParm.offset = 1
  350. this.getList()
  351. this.arrowDown = true
  352. this.arrowUp = false
  353. },
  354. handleRefresh() {
  355. console.log('点击了重置')
  356. this.table.getdataListParm.parammaps.bcode = ''
  357. this.table.getdataListParm.parammaps.bname = ''
  358. this.table.getdataListParm.parammaps.allowratio = ''
  359. this.table.getdataListParm.parammaps.autozone = ''
  360. this.table.getdataListParm.parammaps.autosecond = ''
  361. this.table.getdataListParm.parammaps.enable = ''
  362. this.table.getdataListParm.offset = 1
  363. this.getList()
  364. },
  365. changeAutosecond(item) {
  366. this.table.temp.autosecondname = this.jumpDelayList.find(obj => obj.value === item).label
  367. console.log(this.table.temp.autosecondname)
  368. },
  369. handleCreate() {
  370. console.log('点击了新增')
  371. // 编辑true/不可编辑false
  372. // 新增操true,编辑false,编辑保存false
  373. for (let i = 0; i < this.table.list.length; i++) {
  374. if (this.table.list[i].Edit == true) {
  375. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  376. return false
  377. }
  378. }
  379. this.table.temp.autosecondname = ''
  380. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'isstart': 1, 'bname': '', 'bcode': '', 'allowratio': '', 'autozone': '', 'autosecond': '0', 'autosecondname': '禁用','scopeherdid':'','classid':'' })
  381. },
  382. createData(row) {
  383. console.log('点击了新增保存', row)
  384. this.table.temp.pastureid = Cookies.get('pastureid')
  385. this.table.temp.bcode = row.bcode
  386. this.table.temp.bname = row.bname
  387. this.table.temp.allowratio = row.allowratio
  388. this.table.temp.autozone = row.autozone
  389. this.table.temp.autosecond = row.autosecond
  390. if (this.table.temp.autosecondname == '') {
  391. this.table.temp.autosecondname = row.autosecondname
  392. } else {
  393. this.table.temp.autosecondname = this.table.temp.autosecondname
  394. }
  395. this.table.temp.AUFNR = row.AUFNR
  396. this.table.temp.isstart = row.isstart
  397. this.table.temp.enable = row.enable
  398. // 检验用户名称/角色是否为空
  399. if (this.table.temp.bname == '' && this.table.temp.bcode == '') {
  400. this.$message({ type: 'error', message: '栏舍名称/栏舍编号/牛舍类型/牛群不能为空', duration: 2000 })
  401. return false
  402. }else if (this.table.temp.bname == '') {
  403. this.$message({ type: 'error', message: '栏舍名称不能为空', duration: 2000 })
  404. return false
  405. } else if (this.table.temp.bcode == '') {
  406. this.$message({ type: 'error', message: '栏舍编号不能为空', duration: 2000 })
  407. return false
  408. }
  409. // if (this.table.temp.bcode.length > 8) {
  410. // this.$message({ type: 'error', message: '栏舍编号请输入1-8位数字', duration: 2000 })
  411. // return false
  412. // }
  413. if (this.table.temp.allowratio !== '') {
  414. console.log(this.table.temp.allowratio)
  415. const allowratio = /^[0-9]\d*$/
  416. if (!allowratio.test(parseFloat(this.table.temp.allowratio))) {
  417. this.$message({ type: 'error', message: '允许误差数请输入大于等于0的整数', duration: 2000 })
  418. return false
  419. }
  420. } else {
  421. this.table.temp.allowratio = '0'
  422. }
  423. if (this.table.temp.autozone !== '') {
  424. console.log(this.table.temp.autozone)
  425. const autozone = /^(\d|[1-9]\d|1[0-1]\d|120)$/
  426. if (!autozone.test(parseFloat(this.table.temp.autozone))) {
  427. this.$message({ type: 'error', message: '跳转重量域请输入大于等于0小于等于120的整数', duration: 2000 })
  428. return false
  429. }
  430. } else {
  431. this.table.temp.autozone = '0'
  432. }
  433. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  434. if (pattern.test(this.table.temp.eqcode)) {
  435. this.$message({ type: 'error', message: 'TMR设备编号不可输入特殊字符', duration: 2000 })
  436. return false
  437. }
  438. if (pattern.test(this.table.temp.tname)) {
  439. this.$message({ type: 'error', message: 'TMR设备名称不可输入特殊字符', duration: 2000 })
  440. return false
  441. }
  442. this.isokDisable = true
  443. setTimeout(() => {
  444. this.isokDisable = false
  445. }, 1000)
  446. this.requestParam.name = 'insertBar'
  447. this.requestParam.parammaps = this.table.temp
  448. PostDataByName(this.requestParam).then(response => {
  449. console.log('新增保存发送参数', this.requestParam)
  450. if (response.msg !== 'fail') {
  451. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  452. this.getList()
  453. } else {
  454. const isRepeat = new RegExp('Duplicate entry :bar_bcode')
  455. if (isRepeat.test(response.data)) {
  456. this.$notify({ type: 'error', message: '栏舍编号不可重复,请重新录入', duration: 2000 })
  457. return false
  458. }
  459. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  460. }
  461. })
  462. },
  463. createCancel(row) {
  464. console.log('点击了新增取消')
  465. for (let i = 0; i < this.table.list.length; i++) {
  466. if (row.myId === this.table.list[i].myId) {
  467. var listIndex = this.table.list.indexOf(this.table.list[i])
  468. }
  469. if (listIndex > -1) {
  470. this.table.list.splice(listIndex, 1)
  471. return
  472. }
  473. }
  474. },
  475. handleUpdate(row) {
  476. console.log('点击了编辑', row)
  477. for (let i = 0; i < this.table.list.length; i++) {
  478. if (this.table.list[i].Edit == true) {
  479. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  480. return false
  481. }
  482. }
  483. // 编辑true,不可编辑false
  484. row.Edit = true
  485. row.NoEdit = false
  486. // 新增false,编辑false,编辑保存true
  487. row.isCreate = false
  488. row.isUpdate = false
  489. row.isUpdateSave = true
  490. row.autosecond = String(row.autosecond)
  491. this.table.temp.autosecondname = row.autosecondname
  492. this.table.temp.autosecond = row.autosecond
  493. },
  494. updateData(row) {
  495. console.log('点击了编辑保存', row)
  496. this.table.temp.pastureid = Cookies.get('pastureid')
  497. this.table.temp.bcode = row.bcode
  498. this.table.temp.bname = row.bname
  499. this.table.temp.allowratio = row.allowratio
  500. this.table.temp.autozone = row.autozone
  501. this.table.temp.autosecond = row.autosecond
  502. this.table.temp.autosecondname = this.table.temp.autosecondname
  503. this.table.temp.isstart = row.isstart
  504. this.table.temp.enable = row.enable
  505. this.table.temp.id = row.id
  506. this.table.temp.AUFNR = row.AUFNR
  507. // 检验用户名称/角色是否为空
  508. if (this.table.temp.bname == '' && this.table.temp.bcode == '') {
  509. this.$message({ type: 'error', message: '栏舍名称/栏舍编号不能为空', duration: 2000 })
  510. return false
  511. }else if (this.table.temp.bname == '') {
  512. this.$message({ type: 'error', message: '栏舍名称不能为空', duration: 2000 })
  513. return false
  514. } else if (this.table.temp.bcode == '') {
  515. this.$message({ type: 'error', message: '栏舍编号不能为空', duration: 2000 })
  516. return false
  517. }
  518. if (this.table.temp.allowratio !== '') {
  519. console.log(this.table.temp.allowratio)
  520. const allowratio = /^[0-9]\d*$/
  521. if (!allowratio.test(parseFloat(this.table.temp.allowratio))) {
  522. this.$message({ type: 'error', message: '允许误差数请输入大于等于0的整数', duration: 2000 })
  523. return false
  524. }
  525. } else {
  526. this.table.temp.allowratio = '0'
  527. }
  528. if (this.table.temp.autozone !== '') {
  529. console.log(this.table.temp.autozone)
  530. const autozone = /^(\d|[1-9]\d|1[0-1]\d|120)$/
  531. if (!autozone.test(parseFloat(this.table.temp.autozone))) {
  532. this.$message({ type: 'error', message: '跳转重量域请输入大于等于0小于等于120的整数', duration: 2000 })
  533. return false
  534. }
  535. } else {
  536. this.table.temp.autozone = '0'
  537. }
  538. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  539. if (pattern.test(this.table.temp.eqcode)) {
  540. this.$message({ type: 'error', message: 'TMR设备编号不可输入特殊字符', duration: 2000 })
  541. return false
  542. }
  543. if (pattern.test(this.table.temp.tname)) {
  544. this.$message({ type: 'error', message: 'TMR设备名称不可输入特殊字符', duration: 2000 })
  545. return false
  546. }
  547. this.isokDisable = true
  548. setTimeout(() => {
  549. this.isokDisable = false
  550. }, 1000)
  551. this.requestParam.name = 'updateBar'
  552. this.requestParam.parammaps = this.table.temp
  553. PostDataByName(this.requestParam).then(response => {
  554. console.log('新增保存发送参数', this.requestParam)
  555. if (response.msg !== 'fail') {
  556. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  557. this.getList()
  558. } else {
  559. const isRepeat = new RegExp('Duplicate entry :bar_bcode')
  560. if (isRepeat.test(response.data)) {
  561. this.$notify({ type: 'error', message: '栏舍编号不可重复,请重新录入', duration: 2000 })
  562. return false
  563. }
  564. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  565. }
  566. })
  567. },
  568. updateCancel(row) {
  569. console.log('点击了编辑取消')
  570. // 编辑false,不可编辑true
  571. row.Edit = false
  572. row.NoEdit = true
  573. // 新增false,编辑true,编辑保存false
  574. row.isCreate = false
  575. row.isUpdate = true
  576. row.isUpdateSave = false
  577. this.getList()
  578. },
  579. handleRowDelete(row) {
  580. console.log('点击了行内删除')
  581. MessageBox.confirm('是否确认删除此信息?', {
  582. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  583. }).then(() => {
  584. this.selectList = []
  585. this.requestParam = {}
  586. this.requestParam.common = { 'returnmap': '0' }
  587. this.requestParam.data = []
  588. this.requestParam.data[0] = { 'name': 'checkDeleteBar', 'type': 'v', 'parammaps': {
  589. 'pastureid': row.pastureid,
  590. 'id': row.id
  591. }}
  592. this.requestParam.data[1] = { 'name': 'deleteBar', 'type': 'e', 'parammaps': {
  593. 'pastureid': row.pastureid,
  594. 'id': row.id
  595. }}
  596. ExecDataByConfig(this.requestParam).then(response => {
  597. console.log('删除保存发送参数', this.requestParam)
  598. if (response.msg === 'fail') {
  599. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  600. } else {
  601. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  602. this.getList()
  603. }
  604. })
  605. }).catch(() => {
  606. this.$message({ type: 'info', message: '已取消删除' })
  607. })
  608. },
  609. handleSelectionChange(val) {
  610. console.log('勾选数据', val)
  611. this.selectList = val
  612. },
  613. form_delete() {
  614. console.log('点击了删除')
  615. if (this.selectList.length == 0) {
  616. this.$message({ type: 'error', message: '请选择舍组栏信息', duration: 2000 })
  617. } else {
  618. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  619. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  620. }).then(() => {
  621. console.log(this.selectList)
  622. this.requestParam = {}
  623. this.requestParam.common = { 'returnmap': '0' }
  624. this.requestParam.data = []
  625. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  626. this.requestParam.data[0].children = []
  627. this.requestParam.data[0].children[0] = { 'name': 'checkDeleteBar', 'type': 'v', 'parammaps': {
  628. id: '@insertSpotList.id',
  629. pastureid: '@insertSpotList.pastureid'
  630. }}
  631. this.requestParam.data[0].children[1] = { 'name': 'deleteBar', 'type': 'e', 'parammaps': {
  632. id: '@insertSpotList.id',
  633. pastureid: '@insertSpotList.pastureid'
  634. }}
  635. ExecDataByConfig(this.requestParam).then(response => {
  636. console.log('删除保存发送参数', this.requestParam)
  637. if (response.msg === 'fail') {
  638. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  639. } else {
  640. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  641. this.getList()
  642. }
  643. })
  644. })
  645. }
  646. },
  647. handleChangeOrder() {
  648. this.isOrder = false
  649. this.rowDrop()
  650. },
  651. saveChangeOrder() {
  652. // 保存顺序
  653. var sortArr = []
  654. for (let i = 0; i < this.table.list.length; i++) {
  655. var obj = {}
  656. obj.sort = i + 1
  657. obj.id = this.table.list[i].id
  658. obj.pastureid = this.table.list[i].pastureid
  659. sortArr.push(obj)
  660. }
  661. this.requestParam = {}
  662. this.requestParam.common = { 'returnmap': '0' }
  663. this.requestParam.data = []
  664. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': sortArr }}
  665. this.requestParam.data[0].children = []
  666. this.requestParam.data[0].children[0] = { 'name': 'updateBarSort', 'type': 'e', 'parammaps': {
  667. id: '@insertSpotList.id',
  668. pastureid: '@insertSpotList.pastureid',
  669. sort: '@insertSpotList.sort'
  670. }}
  671. this.table.listLoading = true
  672. ExecDataByConfig(this.requestParam).then(response => {
  673. console.log('顺序切换保存发送参数', this.requestParam)
  674. this.table.listLoading = false
  675. if (response.msg === 'fail') {
  676. this.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  677. } else {
  678. this.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  679. this.getList()
  680. this.isOrder = true
  681. }
  682. })
  683. },
  684. cancelChangeOrder() {
  685. // 取消顺序
  686. this.getList()
  687. this.isOrder = true
  688. },
  689. // 行拖拽
  690. rowDrop() {
  691. console.log(document.querySelector('#table .el-table__body-wrapper tbody'))
  692. const tbody = document.querySelector('#table .el-table__body-wrapper tbody')
  693. const that = this
  694. var sortable = Sortable.create(tbody, {
  695. disabled: that.dropState,
  696. onChoose({ newIndex, oldIndex }) {
  697. console.log(that.isOrder, 'that.isOrder == false')
  698. console.log(that.dropState, 'that.dropState')
  699. if (that.dropState == true || that.isOrder == true) {
  700. sortable.destroy()
  701. }
  702. },
  703. onEnd({ newIndex, oldIndex }) {
  704. const currRow = that.table.list.splice(oldIndex, 1)[0]
  705. that.table.list.splice(newIndex, 0, currRow)
  706. console.log('currRow', currRow)
  707. console.log('oldIndex', oldIndex)
  708. console.log('索引newIndex', newIndex)
  709. console.log('拖动数据', currRow)
  710. console.log('上', that.table.list[newIndex - 1])
  711. console.log('下', that.table.list[newIndex + 1])
  712. }
  713. })
  714. },
  715. handleGetSapCode(){
  716. this.dialogFull = false
  717. this.sapCode2.dialogStatus = 'sapCode2'
  718. this.sapCode2.dialogFormVisible = true
  719. },
  720. sapCodeData2(){
  721. this.$refs['sapCode2'].validate(valid => {
  722. if (valid) {
  723. let url = 'authdata/sap/bar'
  724. let data = {
  725. startTime:parseTime(this.sapCode2.temp.inputDatetime[0],'{y}-{m}-{d}'),
  726. endTime:parseTime(this.sapCode2.temp.inputDatetime[1],'{y}-{m}-{d}'),
  727. pastureId:Cookies.get('pastureid')
  728. }
  729. postJson(url,data).then(response => {
  730. if (response.msg !== 'fail') {
  731. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  732. this.sapCode2.dialogFormVisible = false
  733. this.getList()
  734. } else {
  735. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  736. }
  737. })
  738. }
  739. })
  740. },
  741. getIspalyUd(){
  742. let url = 'authdata/GetDataByName'
  743. let data = {
  744. "name":"getSysoptEnable","page":1,"offset":1,"pagecount":1,"returntype":"Map",
  745. "parammaps":{"pastureid":Cookies.get('pastureid'),"inforname":"gmUdSync"}
  746. }
  747. postJson(url,data).then(response => {
  748. if (response.msg !== 'fail') {
  749. if(response.data.list[0].inforvalue == 0){
  750. this.ispalyUd = false
  751. }else{
  752. this.ispalyUd = true
  753. }
  754. } else {
  755. this.$notify({ title: '请求失败', message: response.data, type: 'warning', duration: 2000 })
  756. }
  757. })
  758. },
  759. handleGetUd(){
  760. MessageBox.confirm('是否获取UD栏舍?', {
  761. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  762. }).then(() => {
  763. let url = 'authdata/gm/udbar'
  764. let data = {
  765. pastureId:Cookies.get('pastureid')
  766. }
  767. postJson(url,data).then(response => {
  768. if (response.msg !== 'fail') {
  769. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  770. this.getList()
  771. } else {
  772. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  773. }
  774. })
  775. })
  776. }
  777. }
  778. }
  779. </script>
  780. <style lang="scss" scoped>
  781. .search{margin-top:10px;}
  782. $width:350px;
  783. $left:325px;
  784. .selectInput{
  785. position: relative;
  786. display: inline-block;
  787. .Input{width: $width;position: relative;}
  788. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  789. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  790. .selectUl{
  791. z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
  792. li{
  793. list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
  794. a{float:left;width: 80px;}
  795. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  796. }
  797. }
  798. }
  799. </style>