index.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-input v-model="table.getdataListParm.parammaps.eqcode" :placeholder="$t('InventoryManagement.tmrsbbh')" style="width: 180px;" class="filter-item" clearable />
  5. <el-select v-model="table.getdataListParm.parammaps.classname" filterable placeholder="TMR设备类型" class="filter-item" style="width: 140px;" clearable>
  6. <el-option v-for="item in typeList" :key="item.id" :label="item.label" :value="item.label" />
  7. </el-select>
  8. <el-select v-model="table.getdataListParm.parammaps.enable" filterable :placeholder="$t('formulationEvaluation.sfqy')" class="filter-item" style="width: 120px;" clearable>
  9. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  10. </el-select>
  11. <el-button class="successBorder" @click="form_search">{{$t('common.query')}}</el-button>
  12. <el-button class="successBorder" @click="handleRefresh">{{$t('common.reset')}}</el-button>
  13. </div>
  14. <div class="operation">
  15. <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" @click="handleCreate">{{$t('formulationEvaluation.add')}}</el-button>
  16. <el-button v-if="isRoleEdit" class="danger" icon="el-icon-delete" @click="form_delete">{{$t('formulationEvaluation.del')}}</el-button>
  17. </div>
  18. <div class="table">
  19. <el-table
  20. :key="table.tableKey"
  21. v-loading="table.listLoading"
  22. element-loading-text="给我一点时间"
  23. :data="table.list"
  24. border
  25. fit
  26. highlight-current-row
  27. style="width: 100%;"
  28. :row-style="rowStyle"
  29. :cell-style="cellStyle"
  30. class="elTable table-fixed"
  31. @selection-change="handleSelectionChange"
  32. >
  33. <el-table-column type="selection" align="center" width="50" />
  34. <el-table-column :label="$t('formulationEvaluation.xh')" align="center" type="index" width="50px">
  35. <template slot-scope="scope">
  36. <span v-if="table.pageNum">{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  37. <span v-else>1</span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="TMR设备编号" min-width="100px" align="center">
  41. <template slot-scope="scope">
  42. <span v-if="scope.row.NoEdit">{{ scope.row.eqcode }}</span>
  43. <el-input v-if="scope.row.Edit" v-model="scope.row.eqcode" placeholder="1-32个字符" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  44. </template>
  45. </el-table-column>
  46. <el-table-column label="TMR设备名称" min-width="110px" align="center">
  47. <template slot-scope="scope">
  48. <span v-if="scope.row.NoEdit">{{ scope.row.tname }}</span>
  49. <el-input v-if="scope.row.Edit" v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:95%;padding:10px 0;" maxlength="32" />
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="容量(m³)" min-width="110px" align="center">
  53. <template slot-scope="scope">
  54. <span v-if="scope.row.NoEdit">{{ scope.row.volume }}</span>
  55. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.volume" type="number" style="width:98%;padding:10px 0;" />
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="车辆颜色" min-width="70px" align="center">
  59. <template slot-scope="scope">
  60. <el-color-picker v-model="scope.row.tcolor" size="mini" :predefine="predefineColors" style="vertical-align: middle;" :disabled="scope.row.NoEdit" />
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="数据采集卡编号" min-width="90px" align="center">
  64. <template slot-scope="scope">
  65. <span v-if="scope.row.NoEdit">{{ scope.row.datacaptureno }}</span>
  66. <el-input v-if="scope.row.Edit" v-model="scope.row.datacaptureno" type="number" step="0.01" style="width:95%;padding:10px 0;" />
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="TMR设备类型" min-width="110px" align="center">
  70. <template slot-scope="scope">
  71. <span v-if="scope.row.NoEdit">{{ scope.row.tclassname }}</span>
  72. <el-select v-if="scope.row.Edit" v-model="scope.row.tclassid" filterable :disabled="scope.row.islock == 1" placeholder="TMR设备类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeType">
  73. <el-option v-for="item in typeList" :key="item.id" :label="item.label" :value="item.value" />
  74. </el-select>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="最大搅拌量(KG)" min-width="110px" align="center">
  78. <template slot-scope="scope">
  79. <span v-if="scope.row.NoEdit">{{ scope.row.maxstirfeed }}</span>
  80. <el-input v-if="scope.row.Edit" v-model="scope.row.maxstirfeed" style="width: 80%;" />
  81. </template>
  82. </el-table-column>
  83. <el-table-column :label="$t('formulationEvaluation.tzzly')"" min-width="85px" 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" type="textarea" :disabled="scope.row.autosecond=='0'" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:95%;padding:10px 0;" />
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="跳转延时(s)" min-width="100px" 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 placeholder="跳转延时" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeAutosecond(value,scope.row)}">
  93. <el-option v-for="item in jumpDelayList" :key="item.value" :label="item.label" :value="item.value" />
  94. </el-select>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="数据接口" min-width="110px" align="center">
  98. <template slot-scope="scope">
  99. <span v-if="scope.row.NoEdit">{{ scope.row.datainterface }}</span>
  100. <el-select v-if="scope.row.Edit" v-model="scope.row.datainterface" filterable placeholder="TMR数据接口" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeDataInterface(value, scope.row)}">
  101. <el-option v-for="item in dataInterfaceList" :key="item.value" :label="item.label" :value="item.value" />
  102. </el-select>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="Imei" min-width="100px" align="center">
  106. <template slot-scope="scope">
  107. <span v-if="scope.row.NoEdit">{{ scope.row.imei }}</span>
  108. <el-input v-if="scope.row.Edit" v-model="scope.row.imei" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:95%;padding:10px 0;" />
  109. </template>
  110. </el-table-column>
  111. <!--
  112. "自走式", value: "1";"固定式", value: "2";撒料设备", value: "3";"小料设备", value: "4" : 固定和小科不能使用指定设备-->
  113. <el-table-column label="指定设备" min-width="100px" align="center">
  114. <template slot-scope="scope">
  115. <span v-if="scope.row.NoEdit">{{ scope.row.appointName }}</span>
  116. <el-select v-if="scope.row.Edit" v-model="scope.row.appointName" filterable placeholder="指定设备" class="filter-item" style="width:95%;padding:10px 0;" @change="changeAppoint" :disabled="scope.row.tclassid =='2' ||scope.row.tclassid =='4' ">
  117. <el-option v-for="item in appoinsList" :key="item.id" :label="item.tname" :value="item.id" />
  118. </el-select>
  119. </template>
  120. </el-table-column>
  121. <el-table-column :label="$t('formulationEvaluation.remark')" min-width="90px" align="center">
  122. <template slot-scope="scope">
  123. <span v-if="scope.row.NoEdit">{{ scope.row.remark }}</span>
  124. <el-input v-if="scope.row.Edit" v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:95%;padding:10px 0;" />
  125. </template>
  126. </el-table-column>
  127. <el-table-column :label="$t('formulationEvaluation.sfqy')" min-width="70px" align="center">
  128. <template slot-scope="scope">
  129. <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)" />
  130. </template>
  131. </el-table-column>
  132. <el-table-column :label="$t('errorAnalysis.cz')" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
  133. <template slot-scope="{row}">
  134. <!-- 新增 -->
  135. <el-button v-if="row.isCreate" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="createData(row)" />
  136. <span v-if="row.isCreate" class="centerSpan">|</span>
  137. <el-button v-if="row.isCreate" class="minCancel" icon="el-icon-close" @click="createCancel(row)" />
  138. <!-- 编辑 -->
  139. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  140. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  141. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" />
  142. <!-- 编辑保存 -->
  143. <el-button v-if="row.isUpdateSave" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData(row)" />
  144. <span v-if="row.isUpdateSave" class="centerSpan">|</span>
  145. <el-button v-if="row.isUpdateSave" class="minCancel" icon="el-icon-close" @click="updateCancel(row)" />
  146. </template>
  147. </el-table-column>
  148. </el-table>
  149. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  150. </div>
  151. </div>
  152. </template>
  153. <script>
  154. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetDataByNames, checkButtons } from '@/api/common'
  155. import Cookies from 'js-cookie'
  156. import Pagination from '@/components/Pagination'
  157. import { MessageBox } from 'element-ui'
  158. export default {
  159. name: 'EquipmentTMR',
  160. components: { Pagination },
  161. data() {
  162. return {
  163. predefineColors: [
  164. '#F44336', '#E91E63', '#9C27B0', '#673AB7', '#3F51B5', '#2196F3', '#03A9F4', '#00BCD4', '#009688', '#4CAF50', '#8BC34A', '#CDDC39', '#FFEB3B', '#FFC107', '#FF9800', '#FF5722', '#795548', '#9E9E9E', '#607D8B'
  165. ],
  166. isRoleEdit: [],
  167. requestParams: [
  168. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['TMR设备类型'] },
  169. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['跳转延时'] },
  170. { name: 'getDictByName3', offset: 0, pagecount: 0, params: ['数据接口'] }
  171. ],
  172. typeList: [], // TMR设备类型
  173. enableList: [{ id: 1, name: '是' }, { id: 0, name: '否' }], // 是否启用
  174. jumpDelayList: [], // 跳转延时
  175. dataInterfaceList: [], // 数据接口
  176. getAppoints:{
  177. name:"getTTMRJB",
  178. page:1,
  179. offset:1,
  180. pagecount:50,
  181. returntype:"Map",
  182. parammaps:{ pastureid: Cookies.get('pastureid'),} //{"pastureid":"1654779860"}
  183. },
  184. table: {
  185. getdataListParm: {
  186. name: 'getTMRList',
  187. page: 1,
  188. offset: 1,
  189. pagecount: parseInt(Cookies.get('pageCount')),
  190. returntype: 'Map',
  191. parammaps: {
  192. pastureid: Cookies.get('pastureid'),
  193. eqcode: '',
  194. classname: '',
  195. enable: '',
  196. eqtype: '1'
  197. }
  198. },
  199. tableKey: 0,
  200. list: [],
  201. total: 0,
  202. listLoading: true,
  203. temp: {}
  204. },
  205. requestParam: {},
  206. isokDisable: false,
  207. selectList: [],
  208. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  209. cellStyle: { padding: 0 + 'px' },
  210. appoinsList:[],
  211. appoinObj:{
  212. appoint:0,
  213. appointName:""
  214. }
  215. }
  216. },
  217. created() {
  218. this.getList()
  219. this.getDownList()
  220. this.getButtons()
  221. this.getAppointHttp()
  222. },
  223. methods: {
  224. // 筛选值
  225. changeAppoint(val){
  226. const arr= this.appoinsList.filter(item=>{
  227. return item.id === val;
  228. })
  229. this.appoinObj.appoint = arr && arr[0].id || 0;
  230. this.appoinObj.appointName =arr && arr[0].tname;
  231. console.log( this.appoinObj,'hss----111')
  232. },
  233. // 获取指定设备的数据
  234. getAppointHttp(){
  235. GetDataByName(this.getAppoints).then(res => {
  236. this.appoinsList = res.data.list;
  237. console.log(this.appoinsList,'response----hss')
  238. })
  239. },
  240. getButtons() {
  241. const Edit = 'EquipmentTMR'
  242. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  243. this.isRoleEdit = isRoleEdit
  244. console.log(this.isRoleEdit)
  245. },
  246. getDownList() {
  247. GetDataByNames(this.requestParams).then(response => {
  248. this.typeList = response.data.getDictByName.list
  249. this.jumpDelayList = response.data.getDictByName2.list
  250. this.dataInterfaceList = response.data.getDictByName3.list
  251. })
  252. },
  253. getList() {
  254. this.table.listLoading = true
  255. GetDataByName(this.table.getdataListParm).then(response => {
  256. console.log('table数据', response.data.list)
  257. if (response.data.list !== null) {
  258. for (let i = 0; i < response.data.list.length; i++) {
  259. this.$set(response.data.list[i], 'Edit', false) // 编辑
  260. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  261. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  262. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  263. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  264. }
  265. this.table.list = response.data.list
  266. this.table.pageNum = response.data.pageNum
  267. this.table.pageSize = response.data.pageSize
  268. } else {
  269. this.table.list = []
  270. }
  271. this.table.total = response.data.total
  272. setTimeout(() => {
  273. this.table.listLoading = false
  274. }, 100)
  275. })
  276. },
  277. handleEnableChange() {
  278. console.log('点击了是否启用')
  279. },
  280. form_search() {
  281. console.log('点击了查询')
  282. this.table.getdataListParm.offset = 1
  283. this.getList()
  284. },
  285. handleRefresh() {
  286. console.log('点击了重置')
  287. this.table.getdataListParm.parammaps.eqcode = ''
  288. this.table.getdataListParm.parammaps.classname = ''
  289. this.table.getdataListParm.parammaps.enable = ''
  290. this.table.getdataListParm.parammaps.eqtype = '1'
  291. this.table.getdataListParm.offset = 1
  292. this.getList()
  293. },
  294. handleCreate() {
  295. console.log('点击了新增')
  296. // 编辑true/不可编辑false
  297. // 新增操true,编辑false,编辑保存false
  298. for (let i = 0; i < this.table.list.length; i++) {
  299. if (this.table.list[i].Edit == true) {
  300. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  301. return false
  302. }
  303. }
  304. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'eqcode': '', 'tname': '', 'datacaptureno': '', 'tclassid': '', 'maxstirfeed': '', 'tcolor': '#ccc', 'autosecond': '0', 'imei': '','volume':'', 'appoint':0,'appointName':""})
  305. },
  306. // TMR设备类型
  307. changeType(item) {
  308. this.table.temp.tclassname = this.typeList.find(obj => obj.value == item).label
  309. },
  310. // 跳转延时
  311. changeAutosecond(item, row) {
  312. console.log(item, row)
  313. this.table.temp.autosecondname = this.jumpDelayList.find(obj => obj.value == item).label
  314. if (this.table.temp.autosecondname == '禁用') {
  315. row.autozone = ''
  316. }
  317. },
  318. changeDataInterface(item, row) {
  319. console.log(item, row)
  320. // this.table.temp.autosecondname = this.jumpDelayList.find(obj => obj.value === item).label
  321. },
  322. createData(row) {
  323. console.log('点击了新增保存', row)
  324. if (row.autosecond == '0') {
  325. row.autozone = ''
  326. row.autosecondname = ''
  327. this.table.temp.autosecondname = ''
  328. }
  329. this.table.temp.pastureid = Cookies.get('pastureid')
  330. this.table.temp.eqcode = row.eqcode
  331. this.table.temp.tname = row.tname
  332. this.table.temp.datacaptureno = row.datacaptureno
  333. this.table.temp.tclassid = row.tclassid
  334. this.table.temp.tclassname = this.table.temp.tclassname
  335. this.table.temp.maxstirfeed = row.maxstirfeed
  336. this.table.temp.enable = row.enable
  337. this.table.temp.remark = row.remark
  338. this.table.temp.tcolor = row.tcolor
  339. this.table.temp.datainterface = row.datainterface
  340. this.table.temp.autozone = row.autozone
  341. this.table.temp.autosecond = row.autosecond
  342. this.table.temp.autosecondname = this.table.temp.autosecondname
  343. this.table.temp.imei = row.imei
  344. if(this.table.temp.volume == ''){
  345. this.table.temp.volume = 0
  346. }
  347. this.table.temp.volume = parseFloat(row.volume)
  348. // 检验用户名称/角色是否为空
  349. if (this.table.temp.eqcode == '' && this.table.temp.tname == '' && this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  350. this.$message({ type: 'error', message: 'TMR设备编号/TMR设备名称/数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  351. return false
  352. } else if (this.table.temp.tname == '' && this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  353. this.$message({ type: 'error', message: 'TMR设备名称/数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  354. return false
  355. } else if (this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  356. this.$message({ type: 'error', message: '数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  357. return false
  358. } else if (this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  359. this.$message({ type: 'error', message: 'TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  360. return false
  361. } else if (this.table.temp.eqcode == '') {
  362. this.$message({ type: 'error', message: 'TMR设备编号不能为空', duration: 2000 })
  363. return false
  364. } else if (this.table.temp.tname == '') {
  365. this.$message({ type: 'error', message: 'TMR设备名称不能为空', duration: 2000 })
  366. return false
  367. } else if (this.table.temp.datacaptureno == '') {
  368. this.$message({ type: 'error', message: '数据采集卡编号不能为空', duration: 2000 })
  369. return false
  370. } else if (this.table.temp.tclassid == '') {
  371. this.$message({ type: 'error', message: '设备类型不能为空', duration: 2000 })
  372. return false
  373. } else if (this.table.temp.maxstirfeed == '') {
  374. this.$message({ type: 'error', message: '最大搅拌量不能为空', duration: 2000 })
  375. return false
  376. }
  377. const datacaptureno = /^([0-9]|(1[0-5]))$/
  378. if (!datacaptureno.test(parseFloat(this.table.temp.datacaptureno))) {
  379. this.$message({ type: 'error', message: '数据采集卡请输入0-15之间整数', duration: 2000 })
  380. return false
  381. }
  382. if (row.autosecond !== '0') {
  383. const autozone = /^(0|[1-9]|[1-3]\d|40)$/
  384. if (!autozone.test(parseFloat(this.table.temp.autozone))) {
  385. this.$message({ type: 'error', message: '跳转重量域请输入0-40之间整数', duration: 2000 })
  386. return false
  387. }
  388. }
  389. const maxstirfeed = /^[1-9]\d*$/
  390. if (!maxstirfeed.test(parseFloat(this.table.temp.maxstirfeed))) {
  391. this.$message({ type: 'error', message: '最大搅拌量请输入正整数', duration: 2000 })
  392. return false
  393. }
  394. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  395. if (pattern.test(this.table.temp.eqcode)) {
  396. this.$message({ type: 'error', message: 'TMR设备编号不可输入特殊字符', duration: 2000 })
  397. return false
  398. }
  399. if (pattern.test(this.table.temp.tname)) {
  400. this.$message({ type: 'error', message: 'TMR设备名称不可输入特殊字符', duration: 2000 })
  401. return false
  402. }
  403. this.isokDisable = true
  404. setTimeout(() => {
  405. this.isokDisable = false
  406. }, 1000)
  407. this.requestParam.name = 'insertTMR'
  408. this.requestParam.parammaps = this.table.temp
  409. this.requestParam.parammaps.appoint= this.appoinObj.appoint || 0;
  410. this.requestParam.parammaps.appointName= this.appoinObj.appointName || '';
  411. PostDataByName(this.requestParam).then(response => {
  412. console.log('新增保存发送参数', this.requestParam)
  413. if (response.msg !== 'fail') {
  414. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  415. this.getList()
  416. } else {
  417. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  418. }
  419. })
  420. },
  421. createCancel(row) {
  422. console.log('点击了新增取消')
  423. for (let i = 0; i < this.table.list.length; i++) {
  424. if (row.myId === this.table.list[i].myId) {
  425. var listIndex = this.table.list.indexOf(this.table.list[i])
  426. }
  427. if (listIndex > -1) {
  428. this.table.list.splice(listIndex, 1)
  429. return
  430. }
  431. }
  432. },
  433. handleUpdate(row) {
  434. for (let i = 0; i < this.table.list.length; i++) {
  435. if (this.table.list[i].Edit == true) {
  436. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  437. return false
  438. }
  439. }
  440. // 编辑true,不可编辑false
  441. row.Edit = true
  442. row.NoEdit = false
  443. // 新增false,编辑false,编辑保存true
  444. row.isCreate = false
  445. row.isUpdate = false
  446. row.isUpdateSave = true
  447. row.tclassid = String(row.tclassid)
  448. if(row.autosecond == undefined){
  449. this.$set(row,'autosecond','')
  450. this.$set(row,'autosecondname','')
  451. }else{
  452. row.autosecond = String(row.autosecond)
  453. }
  454. this.table.temp.tclassid = row.tclassid
  455. this.table.temp.tclassname = row.tclassname
  456. console.log(row)
  457. console.log(this.table.temp.tclassname)
  458. },
  459. updateData(row) {
  460. // row.appoint= this.appoinObj.appoint;
  461. // row.appointName= this.appoinObj.appointName;
  462. // console.log('点击了编辑保存', row)
  463. if (row.tcolor == null) {
  464. row.tcolor = '#CCCCCC'
  465. }
  466. if (row.autosecond == '0') {
  467. row.autozone = ''
  468. row.autosecondname = ''
  469. this.table.temp.autosecondname = ''
  470. }
  471. this.table.temp.pastureid = Cookies.get('pastureid')
  472. this.table.temp.eqcode = row.eqcode
  473. this.table.temp.tname = row.tname
  474. this.table.temp.datacaptureno = row.datacaptureno
  475. this.table.temp.tclassid = row.tclassid
  476. this.table.temp.tclassname = this.table.temp.tclassname
  477. this.table.temp.maxstirfeed = row.maxstirfeed
  478. this.table.temp.enable = row.enable
  479. this.table.temp.remark = row.remark
  480. this.table.temp.id = row.id
  481. this.table.temp.tcolor = row.tcolor
  482. this.table.temp.imei = row.imei
  483. this.table.temp.datainterface = row.datainterface
  484. this.table.temp.autozone = row.autozone
  485. this.table.temp.autosecond = row.autosecond
  486. this.table.temp.autosecondname = this.table.temp.autosecondname
  487. if(this.table.temp.volume == ''){
  488. this.table.temp.volume = 0
  489. }
  490. this.table.temp.volume = parseFloat(row.volume)
  491. // 检验用户名称/角色是否为空
  492. if (this.table.temp.eqcode == '' && this.table.temp.tname == '' && this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  493. this.$message({ type: 'error', message: 'TMR设备编号/TMR设备名称/数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  494. return false
  495. } else if (this.table.temp.tname == '' && this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  496. this.$message({ type: 'error', message: 'TMR设备名称/数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  497. return false
  498. } else if (this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  499. this.$message({ type: 'error', message: '数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  500. return false
  501. } else if (this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  502. this.$message({ type: 'error', message: 'TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  503. return false
  504. } else if (this.table.temp.eqcode == '') {
  505. this.$message({ type: 'error', message: 'TMR设备编号不能为空', duration: 2000 })
  506. return false
  507. } else if (this.table.temp.tname == '') {
  508. this.$message({ type: 'error', message: '设备名称不能为空', duration: 2000 })
  509. return false
  510. } else if (this.table.temp.datacaptureno == '') {
  511. this.$message({ type: 'error', message: '数据采集卡编号不能为空', duration: 2000 })
  512. return false
  513. } else if (this.table.temp.tclassid == '') {
  514. this.$message({ type: 'error', message: '设备类型不能为空', duration: 2000 })
  515. return false
  516. } else if (this.table.temp.maxstirfeed == '') {
  517. this.$message({ type: 'error', message: '最大搅拌量不能为空', duration: 2000 })
  518. return false
  519. }
  520. const datacaptureno = /^([0-9]|(1[0-5]))$/
  521. if (!datacaptureno.test(parseInt(this.table.temp.datacaptureno))) {
  522. this.$message({ type: 'error', message: '数据采集卡请输入0-15之间整数', duration: 2000 })
  523. return false
  524. }
  525. const maxstirfeed = /^[1-9]\d*$/
  526. if (!maxstirfeed.test(parseInt(this.table.temp.maxstirfeed))) {
  527. this.$message({ type: 'error', message: '最大搅拌量请输入正整数', duration: 2000 })
  528. return false
  529. }
  530. console.log(row.autozone, '=0000')
  531. if (row.autosecond !== '0') {
  532. const autozone = /^(0|[1-9]|[1-3]\d|40)$/
  533. if (!autozone.test(parseFloat(this.table.temp.autozone))) {
  534. this.$message({ type: 'error', message: '跳转重量域请输入0-40之间整数', duration: 2000 })
  535. return false
  536. }
  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 = 'updateTMR'
  552. this.requestParam.parammaps = this.table.temp
  553. this.requestParam.parammaps.appoint= this.appoinObj.appoint || 0;
  554. this.requestParam.parammaps.appointName= this.appoinObj.appointName || '';
  555. console.log('点击了编辑保存---hss', this.requestParam)
  556. PostDataByName(this.requestParam).then(response => {
  557. console.log('新增保存发送参数', this.requestParam)
  558. if (response.msg !== 'fail') {
  559. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  560. this.getList()
  561. } else {
  562. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  563. }
  564. })
  565. },
  566. updateCancel(row) {
  567. console.log('点击了编辑取消')
  568. // 编辑false,不可编辑true
  569. row.Edit = false
  570. row.NoEdit = true
  571. // 新增false,编辑true,编辑保存false
  572. row.isCreate = false
  573. row.isUpdate = true
  574. row.isUpdateSave = false
  575. // row.appoint= this.appoinObj.appoint;
  576. // row.appointName= this.appoinObj.appointName;
  577. this.getList()
  578. },
  579. // 删除
  580. handleRowDelete(row) {
  581. console.log('点击了行内删除')
  582. MessageBox.confirm('是否确认删除此信息?', {
  583. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  584. }).then(() => {
  585. this.selectList = []
  586. this.appoinObj={};
  587. this.requestParam = {}
  588. this.requestParam.common = { 'returnmap': '0' }
  589. this.requestParam.data = []
  590. this.requestParam.data[0] = { 'name': 'checkDeleteTmr', 'type': 'v', 'parammaps': {
  591. 'pastureid': row.pastureid,
  592. 'id': row.id
  593. }}
  594. this.requestParam.data[1] = { 'name': 'deleteTMR', '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: '请选择TMR设备信息', 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': 'checkDeleteTmr', 'type': 'v', 'parammaps': {
  630. id: '@insertSpotList.id',
  631. pastureid: '@insertSpotList.pastureid'
  632. }}
  633. this.requestParam.data[0].children[1] = { 'name': 'deleteTMR', '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. }
  650. }
  651. </script>
  652. <style lang="scss" scoped>
  653. .search{margin-top:10px;}
  654. </style>