index.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-input v-model="table.getdataListParm.parammaps.bname" :placeholder="$t('driver.lsmc')" style="width: 180px;" class="filter-item" clearable />
  5. <el-input v-model="table.getdataListParm.parammaps.bcode" :placeholder="$t('driver.lsbh')" 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="$t('driver.xzsstj')" 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>{{$t('driver.yxwcs')}}</a><el-input v-model="table.getdataListParm.parammaps.allowratio" type="text" style="width: 245px;" /></li>
  15. <li><a>{{$t('driver.tzzly')}}</a><el-input v-model="table.getdataListParm.parammaps.autozone" type="text" style="width: 245px;" /></li>
  16. <li>
  17. <a>{{$t('driver.tzys')}}</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">{{$t('driver.hqspanccode')}}</el-button>
  42. <el-button v-if="isRoleEdit && ispalyUd" class="success" icon="el-icon-plus" @click="handleGetUd">{{$t('driver.hqudls')}}</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="$t('common.tableMsg')"
  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="$t('driver.lsbh')" 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"
  75. :placeholder="$t('supplier.zf1')" 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="$t('driver.yxwcs')" 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="$t('driver.tzzly')" 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="$t('driver.tzys')" 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="$t('errorAnalysis.pen')" 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="$t('driver.qrks')" 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="$t('formulationEvaluation.sfqy')" 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="$t('driver.udcode')" 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="$t('driver.udname')" 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="$t('errorAnalysis.cz')" 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;">{{$t('processAnalysis.total')}}{{ table.total }}{{$t('processAnalysis.tiao')}}</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="$t('dailyExecutionPlan.sjfw')" prop="inputDatetime">
  166. <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" />
  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()">{{$t('common.closed')}}</el-button>
  173. <el-button v-if="sapCode2.dialogStatus==='sapCode2' && isRoleEdit" class="save" :disabled="isokDisable" @click="sapCodeData2()">{{$t('errorAnalysis.confirm')}}</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',
  201. name:this.$t('supplier.yes')}, { id: '0',
  202. name:this.$t('supplier.no') }],
  203. jumpDelayList: [],
  204. barClassList:[],
  205. scopeherdList:[],
  206. cattleorderList:[],
  207. table: {
  208. getdataListParm: {
  209. name: 'getBarList',
  210. page: 1,
  211. offset: 1,
  212. pagecount: '',
  213. returntype: 'Map',
  214. parammaps: {
  215. pastureid: Cookies.get('pastureid'),
  216. bcode: '',
  217. bname: '',
  218. allowratio: '',
  219. autozone: '',
  220. autosecond: '',
  221. enable: ''
  222. }
  223. },
  224. tableKey: 0,
  225. list: [],
  226. total: 0,
  227. listLoading: true,
  228. temp: {}
  229. },
  230. sapCode2:{
  231. dialogFormVisible: false,
  232. dialogStatus: '',
  233. materialtypeList:[],
  234. temp:{
  235. inputDatetime: [parseTime(new Date(), '{y}-{m}-{d}'), parseTime(new Date(), '{y}-{m}-{d}')],
  236. sapMaterialtype:'',
  237. },
  238. rules: {
  239. inputDatetime :[{required: true, message: this.$t('hardwareTest.bt'), trigger: 'blur' }]
  240. }
  241. },
  242. textMap: {
  243. sapCode2: '获取SAP编码',
  244. },
  245. sapUpload:{
  246. getdataListParm: {
  247. name: 'getSysoptEnable',
  248. page: 1,
  249. offset: 1,
  250. pagecount: 1,
  251. returntype: 'Map',
  252. parammaps: {
  253. pastureid: Cookies.get('pastureid'),
  254. inforname: 'xdmyBarSync'
  255. }
  256. },
  257. isSap: false
  258. },
  259. requestParam: {},
  260. isokDisable: false,
  261. selectList: [],
  262. arrowDown: true,
  263. arrowUp: false,
  264. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  265. cellStyle: { padding: 0 + 'px' },
  266. dropState: false,
  267. isOrder: true,
  268. ispalyUd: true,
  269. myHeight:document.documentElement.clientHeight - 85- 150
  270. }
  271. },
  272. created() {
  273. this.getIspalyUd()
  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. console.log(isRoleEdit,'hss------')
  310. this.isRoleEdit = isRoleEdit
  311. },
  312. getDownList() {
  313. GetDataByNames(this.requestParams).then(response => {
  314. this.jumpDelayList = response.data.getDictByName.list
  315. this.barClassList = response.data.getBarClass.list
  316. this.scopeherdList = response.data.getScopeherd.list
  317. this.cattleorderList = response.data.getCattleorder.list
  318. })
  319. },
  320. getList() {
  321. this.table.listLoading = true
  322. GetDataByName(this.table.getdataListParm).then(response => {
  323. console.log('table数据', response.data.list)
  324. if (response.data.list !== null) {
  325. for (let i = 0; i < response.data.list.length; i++) {
  326. this.$set(response.data.list[i], 'Edit', false) // 编辑
  327. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  328. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  329. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  330. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  331. }
  332. this.table.list = response.data.list
  333. this.table.pageNum = response.data.pageNum
  334. this.table.pageSize = response.data.pageSize
  335. } else {
  336. this.table.list = []
  337. }
  338. this.table.total = response.data.total
  339. setTimeout(() => {
  340. this.table.listLoading = false
  341. }, 100)
  342. })
  343. },
  344. handleEnableChange() {
  345. console.log('点击了是否启用')
  346. },
  347. handleConfirmStartChange() {
  348. console.log('点击了确认开始')
  349. },
  350. form_search() {
  351. console.log('点击了查询')
  352. this.table.getdataListParm.offset = 1
  353. this.getList()
  354. this.arrowDown = true
  355. this.arrowUp = false
  356. },
  357. handleRefresh() {
  358. console.log('点击了重置')
  359. this.table.getdataListParm.parammaps.bcode = ''
  360. this.table.getdataListParm.parammaps.bname = ''
  361. this.table.getdataListParm.parammaps.allowratio = ''
  362. this.table.getdataListParm.parammaps.autozone = ''
  363. this.table.getdataListParm.parammaps.autosecond = ''
  364. this.table.getdataListParm.parammaps.enable = ''
  365. this.table.getdataListParm.offset = 1
  366. this.getList()
  367. },
  368. changeAutosecond(item) {
  369. this.table.temp.autosecondname = this.jumpDelayList.find(obj => obj.value === item).label
  370. console.log(this.table.temp.autosecondname)
  371. },
  372. handleCreate() {
  373. console.log('点击了新增')
  374. // 编辑true/不可编辑false
  375. // 新增操true,编辑false,编辑保存false
  376. for (let i = 0; i < this.table.list.length; i++) {
  377. if (this.table.list[i].Edit == true) {
  378. this.$message({ type: 'error', message: this.$t('driver.messageNote'), duration: 2000 })
  379. return false
  380. }
  381. }
  382. this.table.temp.autosecondname = ''
  383. 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':'' })
  384. },
  385. createData(row) {
  386. console.log('点击了新增保存', row)
  387. this.table.temp.pastureid = Cookies.get('pastureid')
  388. this.table.temp.bcode = row.bcode
  389. this.table.temp.bname = row.bname
  390. this.table.temp.allowratio = row.allowratio
  391. this.table.temp.autozone = row.autozone
  392. this.table.temp.autosecond = row.autosecond
  393. if (this.table.temp.autosecondname == '') {
  394. this.table.temp.autosecondname = row.autosecondname
  395. } else {
  396. this.table.temp.autosecondname = this.table.temp.autosecondname
  397. }
  398. this.table.temp.AUFNR = row.AUFNR
  399. this.table.temp.isstart = row.isstart
  400. this.table.temp.enable = row.enable
  401. // 检验用户名称/角色是否为空
  402. if (this.table.temp.bname == '' && this.table.temp.bcode == '') {
  403. this.$message({ type: 'error', message: this.$t('driver.message1'), duration: 2000 })
  404. return false
  405. }else if (this.table.temp.bname == '') {
  406. this.$message({ type: 'error', message: this.$t('driver.message2'), duration: 2000 })
  407. return false
  408. } else if (this.table.temp.bcode == '') {
  409. this.$message({ type: 'error', message: this.$t('driver.message3'), duration: 2000 })
  410. return false
  411. }
  412. // if (this.table.temp.bcode.length > 8) {
  413. // this.$message({ type: 'error', message: '栏舍编号请输入1-8位数字', duration: 2000 })
  414. // return false
  415. // }
  416. if (this.table.temp.allowratio !== '') {
  417. console.log(this.table.temp.allowratio)
  418. const allowratio = /^[0-9]\d*$/
  419. if (!allowratio.test(parseFloat(this.table.temp.allowratio))) {
  420. this.$message({ type: 'error', message: this.$t('message.msg254'), duration: 2000 })
  421. return false
  422. }
  423. } else {
  424. this.table.temp.allowratio = '0'
  425. }
  426. if (this.table.temp.autozone !== '') {
  427. console.log(this.table.temp.autozone)
  428. const autozone = /^(\d|[1-9]\d|1[0-1]\d|120)$/
  429. if (!autozone.test(parseFloat(this.table.temp.autozone))) {
  430. this.$message({ type: 'error', message: this.$t('message.msg255'), duration: 2000 })
  431. return false
  432. }
  433. } else {
  434. this.table.temp.autozone = '0'
  435. }
  436. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  437. if (pattern.test(this.table.temp.eqcode)) {
  438. this.$message({ type: 'error', message: this.$t('message.msg236'), duration: 2000 })
  439. return false
  440. }
  441. if (pattern.test(this.table.temp.tname)) {
  442. this.$message({ type: 'error', message: this.$t('message.msg237'), duration: 2000 })
  443. return false
  444. }
  445. this.isokDisable = true
  446. setTimeout(() => {
  447. this.isokDisable = false
  448. }, 1000)
  449. this.requestParam.name = 'insertBar'
  450. this.requestParam.parammaps = this.table.temp
  451. PostDataByName(this.requestParam).then(response => {
  452. console.log('新增保存发送参数', this.requestParam)
  453. if (response.msg !== 'fail') {
  454. this.$notify({ title: this.$t('common.succes'), message: this.$t('driver.saveSuccess'), type: 'success', duration: 2000 })
  455. this.getList()
  456. } else {
  457. const isRepeat = new RegExp('Duplicate entry :bar_bcode')
  458. if (isRepeat.test(response.data)) {
  459. this.$notify({ type: 'error', message: this.$t('message.msg256'), duration: 2000 })
  460. return false
  461. }
  462. this.$notify({ title: this.$t('driver.saveFail'), message: response.data, type: 'warning', duration: 2000 })
  463. }
  464. })
  465. },
  466. createCancel(row) {
  467. console.log('点击了新增取消')
  468. for (let i = 0; i < this.table.list.length; i++) {
  469. if (row.myId === this.table.list[i].myId) {
  470. var listIndex = this.table.list.indexOf(this.table.list[i])
  471. }
  472. if (listIndex > -1) {
  473. this.table.list.splice(listIndex, 1)
  474. return
  475. }
  476. }
  477. },
  478. handleUpdate(row) {
  479. console.log('点击了编辑', row)
  480. for (let i = 0; i < this.table.list.length; i++) {
  481. if (this.table.list[i].Edit == true) {
  482. this.$message({ type: 'error', message: this.$t('driver.messageNote'), duration: 2000 })
  483. return false
  484. }
  485. }
  486. // 编辑true,不可编辑false
  487. row.Edit = true
  488. row.NoEdit = false
  489. // 新增false,编辑false,编辑保存true
  490. row.isCreate = false
  491. row.isUpdate = false
  492. row.isUpdateSave = true
  493. row.autosecond = String(row.autosecond)
  494. this.table.temp.autosecondname = row.autosecondname
  495. this.table.temp.autosecond = row.autosecond
  496. },
  497. updateData(row) {
  498. console.log('点击了编辑保存', row)
  499. this.table.temp.pastureid = Cookies.get('pastureid')
  500. this.table.temp.bcode = row.bcode
  501. this.table.temp.bname = row.bname
  502. this.table.temp.allowratio = row.allowratio
  503. this.table.temp.autozone = row.autozone
  504. this.table.temp.autosecond = row.autosecond
  505. this.table.temp.autosecondname = this.table.temp.autosecondname
  506. this.table.temp.isstart = row.isstart
  507. this.table.temp.enable = row.enable
  508. this.table.temp.id = row.id
  509. this.table.temp.AUFNR = row.AUFNR
  510. // 检验用户名称/角色是否为空
  511. if (this.table.temp.bname == '' && this.table.temp.bcode == '') {
  512. this.$message({ type: 'error', message: this.$t('message.msg257'), duration: 2000 })
  513. return false
  514. }else if (this.table.temp.bname == '') {
  515. this.$message({ type: 'error', message: this.$t('driver.message2'), duration: 2000 })
  516. return false
  517. } else if (this.table.temp.bcode == '') {
  518. this.$message({ type: 'error', message: this.$t('driver.message3'), duration: 2000 })
  519. return false
  520. }
  521. if (this.table.temp.allowratio !== '') {
  522. console.log(this.table.temp.allowratio)
  523. const allowratio = /^[0-9]\d*$/
  524. if (!allowratio.test(parseFloat(this.table.temp.allowratio))) {
  525. this.$message({ type: 'error', message: this.$t('message.msg254'), duration: 2000 })
  526. return false
  527. }
  528. } else {
  529. this.table.temp.allowratio = '0'
  530. }
  531. if (this.table.temp.autozone !== '') {
  532. console.log(this.table.temp.autozone)
  533. const autozone = /^(\d|[1-9]\d|1[0-1]\d|120)$/
  534. if (!autozone.test(parseFloat(this.table.temp.autozone))) {
  535. this.$message({ type: 'error', message: this.$t('message.msg255'), duration: 2000 })
  536. return false
  537. }
  538. } else {
  539. this.table.temp.autozone = '0'
  540. }
  541. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  542. if (pattern.test(this.table.temp.eqcode)) {
  543. this.$message({ type: 'error', message: this.$t('message.msg236'), duration: 2000 })
  544. return false
  545. }
  546. if (pattern.test(this.table.temp.tname)) {
  547. this.$message({ type: 'error', message: this.$t('message.msg237'), duration: 2000 })
  548. return false
  549. }
  550. this.isokDisable = true
  551. setTimeout(() => {
  552. this.isokDisable = false
  553. }, 1000)
  554. this.requestParam.name = 'updateBar'
  555. this.requestParam.parammaps = this.table.temp
  556. PostDataByName(this.requestParam).then(response => {
  557. console.log('新增保存发送参数', this.requestParam)
  558. if (response.msg !== 'fail') {
  559. this.$notify({ title: this.$t('common.succes'), message: this.$t('driver.saveSuccess'), type: 'success', duration: 2000 })
  560. this.getList()
  561. } else {
  562. const isRepeat = new RegExp('Duplicate entry :bar_bcode')
  563. if (isRepeat.test(response.data)) {
  564. this.$notify({ type: 'error', message: this.$t('message.msg256'), duration: 2000 })
  565. return false
  566. }
  567. this.$notify({ title: this.$t('driver.saveFail'), message: response.data, type: 'warning', duration: 2000 })
  568. }
  569. })
  570. },
  571. updateCancel(row) {
  572. console.log('点击了编辑取消')
  573. // 编辑false,不可编辑true
  574. row.Edit = false
  575. row.NoEdit = true
  576. // 新增false,编辑true,编辑保存false
  577. row.isCreate = false
  578. row.isUpdate = true
  579. row.isUpdateSave = false
  580. this.getList()
  581. },
  582. handleRowDelete(row) {
  583. console.log('点击了行内删除')
  584. MessageBox.confirm( this.$t('common.delMsg'), {
  585. confirmButtonText: this.$t('common.confirm'), cancelButtonText: this.$t('common.cancel'), type: 'warning'
  586. }).then(() => {
  587. this.selectList = []
  588. this.requestParam = {}
  589. this.requestParam.common = { 'returnmap': '0' }
  590. this.requestParam.data = []
  591. this.requestParam.data[0] = { 'name': 'checkDeleteBar', 'type': 'v', 'parammaps': {
  592. 'pastureid': row.pastureid,
  593. 'id': row.id
  594. }}
  595. this.requestParam.data[1] = { 'name': 'deleteBar', 'type': 'e', 'parammaps': {
  596. 'pastureid': row.pastureid,
  597. 'id': row.id
  598. }}
  599. ExecDataByConfig(this.requestParam).then(response => {
  600. console.log('删除保存发送参数', this.requestParam)
  601. if (response.msg === 'fail') {
  602. this.$notify({ title: this.$t('common.delfail'), message: response.data, type: 'warning', duration: 2000 })
  603. } else {
  604. this.$notify({ title: '',message: this.$t('common.delSuccess'), type: 'success', duration: 2000 })
  605. this.getList()
  606. }
  607. })
  608. }).catch(() => {
  609. this.$message({ type: 'info', message: this.$t('common.cancelMsg') })
  610. })
  611. },
  612. handleSelectionChange(val) {
  613. console.log('勾选数据', val)
  614. this.selectList = val
  615. },
  616. form_delete() {
  617. console.log('点击了删除')
  618. if (this.selectList.length == 0) {
  619. this.$message({ type: 'error', message: this.$t('message.msg258'), duration: 2000 })
  620. } else {
  621. MessageBox.confirm(this.$t('message.msg29')+ this.selectList.length + this.$t('message.msg31'), {
  622. confirmButtonText: this.$t('common.confirm'), cancelButtonText: this.$t('common.cancel'), type: 'warning'
  623. }).then(() => {
  624. console.log(this.selectList)
  625. this.requestParam = {}
  626. this.requestParam.common = { 'returnmap': '0' }
  627. this.requestParam.data = []
  628. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  629. this.requestParam.data[0].children = []
  630. this.requestParam.data[0].children[0] = { 'name': 'checkDeleteBar', 'type': 'v', 'parammaps': {
  631. id: '@insertSpotList.id',
  632. pastureid: '@insertSpotList.pastureid'
  633. }}
  634. this.requestParam.data[0].children[1] = { 'name': 'deleteBar', 'type': 'e', 'parammaps': {
  635. id: '@insertSpotList.id',
  636. pastureid: '@insertSpotList.pastureid'
  637. }}
  638. ExecDataByConfig(this.requestParam).then(response => {
  639. console.log('删除保存发送参数', this.requestParam)
  640. if (response.msg === 'fail') {
  641. this.$notify({ title: this.$t('common.delfail'), message: response.data, type: 'warning', duration: 2000 })
  642. } else {
  643. this.$notify({ title: '',message: this.$t('common.delSuccess'), type: 'success', duration: 2000 })
  644. this.getList()
  645. }
  646. })
  647. })
  648. }
  649. },
  650. handleChangeOrder() {
  651. this.isOrder = false
  652. this.rowDrop()
  653. },
  654. saveChangeOrder() {
  655. // 保存顺序
  656. var sortArr = []
  657. for (let i = 0; i < this.table.list.length; i++) {
  658. var obj = {}
  659. obj.sort = i + 1
  660. obj.id = this.table.list[i].id
  661. obj.pastureid = this.table.list[i].pastureid
  662. sortArr.push(obj)
  663. }
  664. this.requestParam = {}
  665. this.requestParam.common = { 'returnmap': '0' }
  666. this.requestParam.data = []
  667. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': sortArr }}
  668. this.requestParam.data[0].children = []
  669. this.requestParam.data[0].children[0] = { 'name': 'updateBarSort', 'type': 'e', 'parammaps': {
  670. id: '@insertSpotList.id',
  671. pastureid: '@insertSpotList.pastureid',
  672. sort: '@insertSpotList.sort'
  673. }}
  674. this.table.listLoading = true
  675. ExecDataByConfig(this.requestParam).then(response => {
  676. console.log('顺序切换保存发送参数', this.requestParam)
  677. this.table.listLoading = false
  678. if (response.msg === 'fail') {
  679. this.$notify({ title: this.$t('message.msg51'), message: response.data, type: 'warning', duration: 2000 })
  680. } else {
  681. this.$notify({ title: '', message: this.$t('message.msg50'), type: 'success', duration: 2000 })
  682. this.getList()
  683. this.isOrder = true
  684. }
  685. })
  686. },
  687. cancelChangeOrder() {
  688. // 取消顺序
  689. this.getList()
  690. this.isOrder = true
  691. },
  692. // 行拖拽
  693. rowDrop() {
  694. console.log(document.querySelector('#table .el-table__body-wrapper tbody'))
  695. const tbody = document.querySelector('#table .el-table__body-wrapper tbody')
  696. const that = this
  697. var sortable = Sortable.create(tbody, {
  698. disabled: that.dropState,
  699. onChoose({ newIndex, oldIndex }) {
  700. console.log(that.isOrder, 'that.isOrder == false')
  701. console.log(that.dropState, 'that.dropState')
  702. if (that.dropState == true || that.isOrder == true) {
  703. sortable.destroy()
  704. }
  705. },
  706. onEnd({ newIndex, oldIndex }) {
  707. const currRow = that.table.list.splice(oldIndex, 1)[0]
  708. that.table.list.splice(newIndex, 0, currRow)
  709. console.log('currRow', currRow)
  710. console.log('oldIndex', oldIndex)
  711. console.log('索引newIndex', newIndex)
  712. console.log('拖动数据', currRow)
  713. console.log('上', that.table.list[newIndex - 1])
  714. console.log('下', that.table.list[newIndex + 1])
  715. }
  716. })
  717. },
  718. handleGetSapCode(){
  719. this.dialogFull = false
  720. this.sapCode2.dialogStatus = 'sapCode2'
  721. this.sapCode2.dialogFormVisible = true
  722. },
  723. sapCodeData2(){
  724. this.$refs['sapCode2'].validate(valid => {
  725. if (valid) {
  726. let url = 'authdata/sap/bar'
  727. let data = {
  728. startTime:parseTime(this.sapCode2.temp.inputDatetime[0],'{y}-{m}-{d}'),
  729. endTime:parseTime(this.sapCode2.temp.inputDatetime[1],'{y}-{m}-{d}'),
  730. pastureId:Cookies.get('pastureid')
  731. }
  732. postJson(url,data).then(response => {
  733. if (response.msg !== 'fail') {
  734. this.$notify({ title: this.$t('common.succes'), message: this.$t('driver.saveSuccess'), type: 'success', duration: 2000 })
  735. this.sapCode2.dialogFormVisible = false
  736. this.getList()
  737. } else {
  738. this.$notify({ title: this.$t('driver.saveFail'), message: response.data, type: 'warning', duration: 2000 })
  739. }
  740. })
  741. }
  742. })
  743. },
  744. getIspalyUd(){
  745. let url = 'authdata/GetDataByName'
  746. let data = {
  747. "name":"getSysoptEnable","page":1,"offset":1,"pagecount":1,"returntype":"Map",
  748. "parammaps":{"pastureid":Cookies.get('pastureid'),"inforname":"gmUdSync"}
  749. }
  750. postJson(url,data).then(response => {
  751. if (response.msg !== 'fail') {
  752. if(response.data.list[0].inforvalue == 0){
  753. this.ispalyUd = false
  754. }else{
  755. this.ispalyUd = true
  756. }
  757. } else {
  758. this.$notify({ title:this.$t('message.msg14'), message: response.data, type: 'warning', duration: 2000 })
  759. }
  760. })
  761. },
  762. handleGetUd(){
  763. MessageBox.confirm(this.$t('message.msg343'), {
  764. confirmButtonText: this.$t('common.confirm'), cancelButtonText: this.$t('common.cancel'), type: 'warning'
  765. }).then(() => {
  766. let url = 'authdata/gm/udbar'
  767. let data = {
  768. pastureId:Cookies.get('pastureid')
  769. }
  770. postJson(url,data).then(response => {
  771. if (response.msg !== 'fail') {
  772. this.$notify({ title: this.$t('common.succes'), message: this.$t('driver.saveSuccess'), type: 'success', duration: 2000 })
  773. this.getList()
  774. } else {
  775. this.$notify({ title: this.$t('driver.saveFail'), message: response.data, type: 'warning', duration: 2000 })
  776. }
  777. })
  778. })
  779. }
  780. }
  781. }
  782. </script>
  783. <style lang="scss" scoped>
  784. .search{margin-top:10px;}
  785. $width:350px;
  786. $left:325px;
  787. .selectInput{
  788. position: relative;
  789. display: inline-block;
  790. .Input{width: $width;position: relative;}
  791. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  792. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  793. .selectUl{
  794. 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;
  795. li{
  796. 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;
  797. a{float:left;width: 80px;}
  798. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  799. }
  800. }
  801. }
  802. </style>