index.vue 37 KB

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