fc2262746564f03ed593ba0f1c8b3d6ac9825c59.svn-base 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436
  1. <template>
  2. <div class="app-container">
  3. <div class="operation">
  4. <el-button v-if="isRoleEdit" class="success" @click="handleCreate">新增</el-button>
  5. <el-button v-if="isRoleEdit" class="danger" @click="handleDelete">删除</el-button>
  6. <el-button class="success" @click="handleFeedBank">饲料库</el-button>
  7. </div>
  8. <div class="search">
  9. <el-input v-model="table.getdataListParm.parammaps.fname" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
  10. <el-select v-model="table.getdataListParm.parammaps.fclassid" filterable placeholder="饲料类别" class="filter-item" style="width: 150px;" clearable>
  11. <el-option v-for="item in feedTypeList" :key="item.id" :label="item.mixname" :value="item.id" />
  12. </el-select>
  13. <el-select v-model="table.getdataListParm.parammaps.source" filterable placeholder="饲料来源" class="filter-item" style="width: 120px;" clearable>
  14. <el-option v-for="item in feedSourcesList" :key="item.id" :label="item.name" :value="item.id" />
  15. </el-select>
  16. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  17. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  18. </el-select>
  19. <div ref="selectInput" class="filter-item selectInput">
  20. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  21. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  22. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  23. <ul v-if="arrowUp" class="selectUl">
  24. <li><a>允许误差数</a><el-input v-model="table.getdataListParm.parammaps.allowratio"type="text" style="width: 245px;" /></li>
  25. <li><a>跳转重量域</a><el-input v-model="table.getdataListParm.parammaps.autozone" type="text" style="width: 245px;" /></li>
  26. <li>
  27. <a>跳转延时</a>
  28. <el-select v-model="table.getdataListParm.parammaps.autosecond" filterable placeholder="跳转延时" class="filter-item" style="width: 245px;" clearable>
  29. <el-option v-for="item in jumpDelayList" :key="item.value" :label="item.label" :value="item.value" />
  30. </el-select>
  31. </li>
  32. <li>
  33. <div style="float: right;">
  34. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  35. <el-button class="miniPrimary" @click="handleSearch">搜索</el-button>
  36. </div>
  37. </li>
  38. </ul>
  39. </div>
  40. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  41. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  42. </div>
  43. <div class="table">
  44. <el-table
  45. :key="table.tableKey"
  46. v-loading="table.listLoading"
  47. element-loading-text="给我一点时间"
  48. :data="table.list"
  49. border
  50. fit
  51. highlight-current-row
  52. style="width: 100%;"
  53. :row-style="rowStyle"
  54. :cell-style="cellStyle"
  55. class="elTable table-fixed"
  56. @selection-change="handleSelectionChange"
  57. >
  58. <el-table-column type="selection" align="center" width="50" />
  59. <el-table-column label="序号" align="center" type="index" width="50px">
  60. <template slot-scope="scope">
  61. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="饲料名称" min-width="130px" align="center">
  65. <template slot-scope="scope">
  66. <span>{{ scope.row.fname }}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="饲料分类" min-width="130px" align="center">
  70. <template slot-scope="scope">
  71. <span>{{ scope.row.fclass }}</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="唯一编码" min-width="110px" align="center">
  75. <template slot-scope="scope">
  76. <span>{{ scope.row.feedcode }}</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="饲料来源" min-width="110px" align="center">
  80. <template slot-scope="scope">
  81. <span>{{ scope.row.source }}</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="计划类型" min-width="110px" align="center">
  85. <template slot-scope="scope">
  86. <span>{{ scope.row.printgroup }}</span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="小料秤" min-width="110px" align="center">
  90. <template slot-scope="scope">
  91. <span>{{ scope.row.smtmrname }}</span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="允许误差数(kg)" min-width="110px" align="center">
  95. <template slot-scope="scope">
  96. <span>{{ scope.row.allowratio }}</span>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="包装单位重量(kg)" min-width="110px" align="center">
  100. <template slot-scope="scope">
  101. <span>{{ scope.row.unitweight }}</span>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="单价" min-width="110px" align="center">
  105. <template slot-scope="scope">
  106. <span>{{ scope.row.uprice }}</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="跳转重量域(kg)" min-width="110px" align="center">
  110. <template slot-scope="scope">
  111. <span>{{ scope.row.autozone }}</span>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="跳转延时" min-width="110px" align="center">
  115. <template slot-scope="scope">
  116. <span>{{ scope.row.autosecondname }}</span>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="确认开始" min-width="110px" align="center">
  120. <template slot-scope="scope">
  121. <span>{{ scope.row.confirmstartname }}</span>
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="继电器位置" min-width="110px" align="center">
  125. <template slot-scope="scope">
  126. <span>{{ scope.row.trgaddress }}</span>
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="无上域" min-width="110px" align="center">
  130. <template slot-scope="scope">
  131. <span v-if="scope.row.jmp == 0">否</span>
  132. <span v-else>是</span>
  133. </template>
  134. </el-table-column>
  135. <el-table-column label="备用字段01" min-width="110px" align="center">
  136. <template slot-scope="scope">
  137. <span>{{ scope.row.backup1 }}</span>
  138. </template>
  139. </el-table-column>
  140. <el-table-column label="备用字段02" min-width="110px" align="center">
  141. <template slot-scope="scope">
  142. <span>{{ scope.row.backup2 }}</span>
  143. </template>
  144. </el-table-column>
  145. <el-table-column label="备用字段03" min-width="110px" align="center">
  146. <template slot-scope="scope">
  147. <span>{{ scope.row.backup3 }}</span>
  148. </template>
  149. </el-table-column>
  150. <el-table-column label="是否启用" min-width="110px" align="center">
  151. <template slot-scope="scope">
  152. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  153. </template>
  154. </el-table-column>
  155. <el-table-column label="操作" align="center" width="320" class-name="small-padding fixed-width" fixed="right">
  156. <template slot-scope="{row}">
  157. <el-button class="miniSuccess" @click="handleNutritive (row)">营养价值</el-button>
  158. <el-button v-if="isRoleEdit" class="miniSuccess" @click="handleRelation(row)">关联</el-button>
  159. <el-button v-if="isRoleEdit" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  160. <el-button v-if="isRoleEdit" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  161. </template>
  162. </el-table-column>
  163. </el-table>
  164. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  165. </div>
  166. <!-- 新增/编辑 -->
  167. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
  168. <div class="app-add">
  169. <el-form ref="temp" :rules="create.rules" :model="create.temp" label-position="right" label-width="155px" style="width: 100%;margin:0 auto 50px">
  170. <el-row>
  171. <el-col :span="24">
  172. <h3 style="width: 160px;text-align: right;">基础信息</h3>
  173. </el-col>
  174. </el-row>
  175. <el-row>
  176. <el-col :span="6">
  177. <el-form-item label="饲料名称:" prop="fname">
  178. <el-input ref="fname" v-model="create.temp.fname" class="filter-item" placeholder="请输入饲料名称" type="textarea" :autosize="{ minRows:1}" maxlength="32" />
  179. </el-form-item>
  180. </el-col>
  181. <el-col :span="6">
  182. <el-form-item label="饲料类别:" prop="fclassid">
  183. <el-select v-model="create.temp.fclassid" filterable placeholder="饲料类别" class="filter-item" style="width: 100%;" @change="changeFeedList">
  184. <el-option v-for="item in feedTypeList" :key="item.id" :label="item.mixname" :value="item.id" />
  185. </el-select>
  186. </el-form-item></el-col>
  187. <el-col :span="6">
  188. <el-form-item label="唯一编码:" prop="feedcode">
  189. <el-input ref="feedcode" v-model="create.temp.feedcode" class="filter-item" placeholder="请输入唯一编码" type="text" />
  190. </el-form-item>
  191. </el-col>
  192. <el-col :span="6">
  193. <el-form-item label="饲料来源:" prop="source">
  194. <el-input ref="source" v-model="create.temp.source" class="filter-item" disabled placeholder="用户自定义" type="text" />
  195. </el-form-item>
  196. </el-col>
  197. </el-row>
  198. <el-row>
  199. <el-col :span="6">
  200. <el-form-item label="计划类型:" prop="printgroupid">
  201. <el-select v-model="create.temp.printgroupid" filterable placeholder="计划类型" class="filter-item" style="width: 100%;" @change="changePlanList">
  202. <el-option v-for="item in planTypeList" :key="item.value" :label="item.label" :value="item.value" />
  203. </el-select>
  204. </el-form-item>
  205. </el-col>
  206. <el-col :span="6">
  207. <el-form-item label="包装单位重量(kg):" prop="unitweight">
  208. <el-input ref="unitweight" v-model="create.temp.unitweight" class="filter-item" placeholder="正整数" type="number" style="width: 100%;" />
  209. </el-form-item>
  210. </el-col>
  211. <el-col :span="6">
  212. <el-form-item label="单价:" prop="uprice">
  213. <el-input ref="uprice" v-model="create.temp.uprice" v-limit class="filter-item" placeholder="最多俩位小数" type="number" step="0.01" style="width: 100%;" />
  214. </el-form-item>
  215. </el-col>
  216. </el-row>
  217. <el-row>
  218. <el-col :span="24">
  219. <h3 style="width: 160px;text-align: right;">搅拌参数</h3>
  220. </el-col>
  221. </el-row>
  222. <el-row>
  223. <el-col :span="6">
  224. <el-form-item label="允许误差数(kg):" prop="allowratio">
  225. <el-input ref="allowratio" v-model="create.temp.allowratio" class="filter-item" placeholder="正整数" type="text" />
  226. </el-form-item>
  227. </el-col>
  228. <el-col :span="6">
  229. <el-form-item label="跳转重量域(kg):" prop="autozone">
  230. <el-input ref="autozone" v-model="create.temp.autozone" :disabled="create.temp.autosecond=='0'" class="filter-item" placeholder="0-50之间的整数" type="text" />
  231. </el-form-item>
  232. </el-col>
  233. <el-col :span="6">
  234. <el-form-item label="跳转延时:" prop="autosecond">
  235. <el-select v-model="create.temp.autosecond" filterable placeholder="跳转延时" class="filter-item" style="width: 100%;" @change="changeAutosecond">
  236. <el-option v-for="item in jumpDelayList" :key="item.value" :label="item.label" :value="item.value" />
  237. </el-select>
  238. </el-form-item>
  239. </el-col>
  240. <el-col :span="6">
  241. <el-form-item label="确认开始:" prop="confirmstart">
  242. <el-select v-model="create.temp.confirmstart" filterabler placeholde="确认开始" class="filter-item" style="width: 100%;" @change="changeConfirmstart">
  243. <el-option v-for="item in confirmStartList" :key="item.id" :label="item.name" :value="item.id" />
  244. </el-select>
  245. </el-form-item>
  246. </el-col>
  247. </el-row>
  248. <el-row>
  249. <el-col :span="6">
  250. <el-form-item label="是否启用:" prop="enable">
  251. <el-select v-model="create.temp.enable" filterable placeholder="是否启用" class="filter-item" style="width: 100%;">
  252. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  253. </el-select>
  254. </el-form-item>
  255. </el-col>
  256. <el-col :span="6">
  257. <el-form-item label="继电器位置:" prop="trgaddress">
  258. <el-input ref="trgaddress" v-model="create.temp.trgaddress" class="filter-item" placeholder="继电器位置" type="number" />
  259. </el-form-item>
  260. </el-col>
  261. <el-col :span="6">
  262. <el-form-item label="小料秤:" prop="smtmrid">
  263. <el-select v-model="create.temp.smtmrid" filterable placeholder="小料秤" clearable class="filter-item" style="width: 100%;" @change="changeSmallMaterial">
  264. <el-option v-for="item in smallMaterialList" :key="item.id" :label="item.tname" :value="item.id" />
  265. </el-select>
  266. </el-form-item>
  267. </el-col>
  268. <el-col :span="6">
  269. <el-form-item label="无上域:" prop="jmp">
  270. <el-select v-model="create.temp.jmp" placeholder="无上域" class="filter-item" style="width: 100%;" @change="changeSmallMaterial">
  271. <el-option v-for="item in jmpList" :key="item.id" :label="item.name" :value="item.id" />
  272. </el-select>
  273. </el-form-item>
  274. </el-col>
  275. </el-row>
  276. <el-row>
  277. <h3 style="width: 160px;text-align: right;">备用字段</h3>
  278. </el-row>
  279. <el-row>
  280. <el-col :span="6">
  281. <el-form-item label="备用字段01:" prop="backup1">
  282. <el-input ref="backup1" v-model="create.temp.backup1" class="filter-item" placeholder="备用字段01" type="text" />
  283. </el-form-item>
  284. </el-col>
  285. <el-col :span="6">
  286. <el-form-item label="备用字段02:" prop="backup2">
  287. <el-input ref="backup2" v-model="create.temp.backup2" class="filter-item" placeholder="备用字段02" type="text" />
  288. </el-form-item>
  289. </el-col>
  290. <el-col :span="6">
  291. <el-form-item label="备用字段03:" prop="backup3">
  292. <el-input ref="backup3" v-model="create.temp.backup3" class="filter-item" placeholder="备用字段03" type="text" />
  293. </el-form-item>
  294. </el-col>
  295. </el-row>
  296. </el-form>
  297. <div slot="footer" class="dialog-footer">
  298. <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  299. <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="success" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
  300. </div>
  301. </div>
  302. </el-dialog>
  303. <!-- 饲料库 -->
  304. <el-dialog :title="textMap[feedBank.dialogStatus]" :visible.sync="feedBank.dialogFormVisible" :close-on-click-modal="false" width="90%">
  305. <div class="app-add">
  306. <div class="search">
  307. <el-input v-model="feedBank.getdataListParm.parammaps.fname" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
  308. <el-select v-model="feedBank.getdataListParm.parammaps.statue" filterabler placeholder="关联状态" class="filter-item" style="width: 120px;" clearable>
  309. <el-option v-for="item in associationStatusList" :key="item.id" :label="item.name" :value="item.id" />
  310. </el-select>
  311. <el-button class="successBorder" @click="handleFeedBankSearch">查询</el-button>
  312. <el-button class="successBorder" @click="handleFeedBankRefresh">重置</el-button>
  313. </div>
  314. <div class="table">
  315. <el-table
  316. :key="feedBank.tableKey"
  317. v-loading="feedBank.listLoading"
  318. element-loading-text="给我一点时间"
  319. :data="feedBank.list"
  320. border
  321. fit
  322. highlight-current-row
  323. style="width: 100%;margin: 0 auto 50px;"
  324. :row-style="rowStyle"
  325. :cell-style="cellStyle"
  326. class="elTable table-fixed"
  327. >
  328. <el-table-column label="序号" align="center" type="index" width="50px" />
  329. <el-table-column label="来源" min-width="90" align="center">
  330. <template slot-scope="scope">
  331. <span>{{ scope.row.sources }}</span>
  332. </template>
  333. </el-table-column>
  334. <el-table-column label="中国饲料号" min-width="100px" align="center">
  335. <template slot-scope="scope">
  336. <span>{{ scope.row.feedcode }}</span>
  337. </template>
  338. </el-table-column>
  339. <el-table-column label="饲料名称" min-width="90px" align="center">
  340. <template slot-scope="scope">
  341. <span>{{ scope.row.fname }}</span>
  342. </template>
  343. </el-table-column>
  344. <el-table-column label="价格" min-width="80px" align="center">
  345. <template slot-scope="scope">
  346. <span>{{ scope.row.price }}</span>
  347. </template>
  348. </el-table-column>
  349. <el-table-column label="样品说明" min-width="90px" align="center">
  350. <template slot-scope="scope">
  351. <span>{{ scope.row.remark }}</span>
  352. </template>
  353. </el-table-column>
  354. <el-table-column label="干物质(DM%)" min-width="70px" align="center">
  355. <template slot-scope="scope">
  356. <span>{{ scope.row.dry }}</span>
  357. </template>
  358. </el-table-column>
  359. <el-table-column label="淀粉(%DM)" min-width="70px" align="center">
  360. <template slot-scope="scope">
  361. <span>{{ scope.row.starch }}</span>
  362. </template>
  363. </el-table-column>
  364. <el-table-column label="粗蛋白(CP%DM)" min-width="75px" align="center">
  365. <template slot-scope="scope">
  366. <span>{{ scope.row.cp }}</span>
  367. </template>
  368. </el-table-column>
  369. <el-table-column label="钙(Ca%DM)" min-width="80px" align="center">
  370. <template slot-scope="scope">
  371. <span>{{ scope.row.ca }}</span>
  372. </template>
  373. </el-table-column>
  374. <el-table-column label="磷(P%DM)" min-width="80px" align="center">
  375. <template slot-scope="scope">
  376. <span>{{ scope.row.p }}</span>
  377. </template>
  378. </el-table-column>
  379. <el-table-column label="产奶净能(%DM)" min-width="80px" align="center">
  380. <template slot-scope="scope">
  381. <span>{{ scope.row.n }}</span>
  382. </template>
  383. </el-table-column>
  384. <el-table-column label="脂肪(%DM)" min-width="70px" align="center">
  385. <template slot-scope="scope">
  386. <span>{{ scope.row.fat }}</span>
  387. </template>
  388. </el-table-column>
  389. <el-table-column label="ADF(%DM)" min-width="80px" align="center">
  390. <template slot-scope="scope">
  391. <span>{{ scope.row.adf }}</span>
  392. </template>
  393. </el-table-column>
  394. <el-table-column label="NDF(%DM)" min-width="80px" align="center">
  395. <template slot-scope="scope">
  396. <span>{{ scope.row.ndf }}</span>
  397. </template>
  398. </el-table-column>
  399. <el-table-column label="NDIP%" min-width="80px" align="center">
  400. <template slot-scope="scope">
  401. <span>{{ scope.row.ndip }}</span>
  402. </template>
  403. </el-table-column>
  404. <el-table-column label="粗灰分(Ash%)" min-width="70px" align="center">
  405. <template slot-scope="scope">
  406. <span>{{ scope.row.ash }}</span>
  407. </template>
  408. </el-table-column>
  409. <el-table-column label="粗料" min-width="70px" align="center">
  410. <template slot-scope="scope">
  411. <span>{{ scope.row.iscu }}</span>
  412. </template>
  413. </el-table-column>
  414. <el-table-column label="关联状态" min-width="70px" align="center">
  415. <template slot-scope="scope">
  416. <span v-if="scope.row.statue==0">否</span>
  417. <span v-if="scope.row.statue==1">是</span>
  418. </template>
  419. </el-table-column>
  420. </el-table>
  421. </div>
  422. <div slot="footer" class="dialog-footer">
  423. <el-button class="cancelClose" @click="feedBank.dialogFormVisible = false; ">关闭</el-button>
  424. </div>
  425. </div>
  426. </el-dialog>
  427. <!-- 关联 -->
  428. <el-dialog :title="textMap[relation.dialogStatus]" :visible.sync="relation.dialogFormVisible" :close-on-click-modal="false" width="90%">
  429. <div class="app-add">
  430. <div class="search">
  431. <el-input v-model="relation.getdataListParm.parammaps.fname" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
  432. <el-button class="successBorder" @click="handleRelationSearch">查询</el-button>
  433. </div>
  434. <div class="table">
  435. <el-table
  436. :key="relation.tableKey"
  437. v-loading="relation.listLoading"
  438. element-loading-text="给我一点时间"
  439. :data="relation.list"
  440. border
  441. fit
  442. highlight-current-row
  443. style="width: 100%;margin: 0 auto 50px;"
  444. :row-style="rowStyle"
  445. :cell-style="cellStyle"
  446. class="elTable table-fixed"
  447. >
  448. <el-table-column label="序号" align="center" type="index" width="50px" />
  449. <el-table-column label="来源" min-width="90" align="center">
  450. <template slot-scope="scope">
  451. <span>{{ scope.row.sources }}</span>
  452. </template>
  453. </el-table-column>
  454. <el-table-column label="中国饲料号" min-width="100px" align="center">
  455. <template slot-scope="scope">
  456. <span>{{ scope.row.feedcode }}</span>
  457. </template>
  458. </el-table-column>
  459. <el-table-column label="饲料名称" min-width="90px" align="center">
  460. <template slot-scope="scope">
  461. <span>{{ scope.row.fname }}</span>
  462. </template>
  463. </el-table-column>
  464. <el-table-column label="价格" min-width="80px" align="center">
  465. <template slot-scope="scope">
  466. <span>{{ scope.row.price }}</span>
  467. </template>
  468. </el-table-column>
  469. <el-table-column label="样品说明" min-width="90px" align="center">
  470. <template slot-scope="scope">
  471. <span>{{ scope.row.remark }}</span>
  472. </template>
  473. </el-table-column>
  474. <el-table-column label="干物质(DM%)" min-width="70px" align="center">
  475. <template slot-scope="scope">
  476. <span>{{ scope.row.dry }}</span>
  477. </template>
  478. </el-table-column>
  479. <el-table-column label="淀粉(%DM)" min-width="70px" align="center">
  480. <template slot-scope="scope">
  481. <span>{{ scope.row.starch }}</span>
  482. </template>
  483. </el-table-column>
  484. <el-table-column label="粗蛋白(CP%DM)" min-width="75px" align="center">
  485. <template slot-scope="scope">
  486. <span>{{ scope.row.cp }}</span>
  487. </template>
  488. </el-table-column>
  489. <el-table-column label="钙(Ca%DM)" min-width="80px" align="center">
  490. <template slot-scope="scope">
  491. <span>{{ scope.row.ca }}</span>
  492. </template>
  493. </el-table-column>
  494. <el-table-column label="磷(P%DM)" min-width="80px" align="center">
  495. <template slot-scope="scope">
  496. <span>{{ scope.row.p }}</span>
  497. </template>
  498. </el-table-column>
  499. <el-table-column label="产奶净能(%DM)" min-width="80px" align="center">
  500. <template slot-scope="scope">
  501. <span>{{ scope.row.n }}</span>
  502. </template>
  503. </el-table-column>
  504. <el-table-column label="脂肪(%DM)" min-width="70px" align="center">
  505. <template slot-scope="scope">
  506. <span>{{ scope.row.fat }}</span>
  507. </template>
  508. </el-table-column>
  509. <el-table-column label="ADF(%DM)" min-width="80px" align="center">
  510. <template slot-scope="scope">
  511. <span>{{ scope.row.adf }}</span>
  512. </template>
  513. </el-table-column>
  514. <el-table-column label="NDF(%DM)" min-width="80px" align="center">
  515. <template slot-scope="scope">
  516. <span>{{ scope.row.ndf }}</span>
  517. </template>
  518. </el-table-column>
  519. <el-table-column label="NDIP%" min-width="80px" align="center">
  520. <template slot-scope="scope">
  521. <span>{{ scope.row.ndip }}</span>
  522. </template>
  523. </el-table-column>
  524. <el-table-column label="粗灰分(Ash%)" min-width="70px" align="center">
  525. <template slot-scope="scope">
  526. <span>{{ scope.row.ash }}</span>
  527. </template>
  528. </el-table-column>
  529. <el-table-column label="粗料" min-width="70px" align="center">
  530. <template slot-scope="scope">
  531. <span>{{ scope.row.iscu }}</span>
  532. </template>
  533. </el-table-column>
  534. <el-table-column label="操作" min-width="150px" align="center" class-name="small-padding fixed-width" fixed="right">
  535. <template slot-scope="{row}">
  536. <el-button v-if="row.statueRelation == '1'" class="miniSuccess" :disabled="isokDisable" @click="disassociateData(row)">取消关联</el-button>
  537. <el-button v-if="row.statueRelation == '0'" class="miniSuccess" :disabled="isokDisable" @click="relationData(row)">关联</el-button>
  538. </template>
  539. </el-table-column>
  540. </el-table>
  541. </div>
  542. <div slot="footer" class="dialog-footer">
  543. <el-button class="cancelClose" @click="relation.dialogFormVisible = false;getList() ">关闭</el-button>
  544. </div>
  545. </div>
  546. </el-dialog>
  547. <!-- 营养价值 -->
  548. <el-dialog :title="textMap[nutritive.dialogStatus]" :visible.sync="nutritive.dialogFormVisible" :close-on-click-modal="false" width="90%">
  549. <div class="app-add">
  550. <el-form ref="temp" :rules="nutritive.rules" :model="nutritive.temp" label-position="right" label-width="160px" style="width: 100%;margin:0 auto 50px">
  551. <el-row>
  552. <el-col :span="6">
  553. <el-form-item label="干物质(DM%):" prop="dry">
  554. <el-input ref="dry" v-model="nutritive.temp.dry" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入干物质" type="number" step="0.01" />
  555. </el-form-item>
  556. </el-col>
  557. <el-col :span="6">
  558. <el-form-item label="淀粉(%DM):" prop="starch">
  559. <el-input ref="starch" v-model="nutritive.temp.starch" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入淀粉" type="number" step="0.01" />
  560. </el-form-item>
  561. </el-col>
  562. <el-col :span="6">
  563. <el-form-item label="粗蛋白(CP%DM):" prop="cp">
  564. <el-input ref="cp" v-model="nutritive.temp.cp" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入粗蛋白" type="number" step="0.01" />
  565. </el-form-item>
  566. </el-col>
  567. <el-col :span="6">
  568. <el-form-item label="钙(Ca%DM):" prop="ca">
  569. <el-input ref="ca" v-model="nutritive.temp.ca" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入钙" type="number" step="0.01" />
  570. </el-form-item>
  571. </el-col>
  572. </el-row>
  573. <el-row>
  574. <el-col :span="6">
  575. <el-form-item label="磷(P%DM):" prop="p">
  576. <el-input ref="p" v-model="nutritive.temp.p" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入磷" type="number" step="0.01" />
  577. </el-form-item>
  578. </el-col>
  579. <el-col :span="6">
  580. <el-form-item label="产奶净能(%DM):" prop="n">
  581. <el-input ref="n" v-model="nutritive.temp.n" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入产奶净能" type="number" step="0.01" />
  582. </el-form-item>
  583. </el-col>
  584. <el-col :span="6">
  585. <el-form-item label="脂肪(%DM):" prop="fat">
  586. <el-input ref="fat" v-model="nutritive.temp.fat" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入脂肪" type="number" step="0.01" />
  587. </el-form-item>
  588. </el-col>
  589. <el-col :span="6">
  590. <el-form-item label="ADF(%DM):" prop="adf">
  591. <el-input ref="adf" v-model="nutritive.temp.adf" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入ADF" type="number" step="0.01" />
  592. </el-form-item>
  593. </el-col>
  594. </el-row>
  595. <el-row>
  596. <el-col :span="6">
  597. <el-form-item label="NDF(%DM):" prop="ndf">
  598. <el-input ref="ndf" v-model="nutritive.temp.ndf" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入NDF" type="number" step="0.01" />
  599. </el-form-item>
  600. </el-col>
  601. <el-col :span="6">
  602. <el-form-item label="NDIP(%):" prop="ndip">
  603. <el-input ref="ndip" v-model="nutritive.temp.ndip" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入NDIP" type="number" step="0.01" />
  604. </el-form-item>
  605. </el-col>
  606. <el-col :span="6">
  607. <el-form-item label="粗灰分(Ash%):" prop="ash">
  608. <el-input ref="ash" v-model="nutritive.temp.ash" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入粗灰分" type="number" min="0.00" step="0.01" />
  609. </el-form-item>
  610. </el-col>
  611. </el-row>
  612. </el-form>
  613. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
  614. <el-button @click="nutritive.dialogFormVisible = false;getList()">关闭</el-button>
  615. <el-button v-if="nutritive.dialogStatus==='nutritive' && isRoleEdit" type="success" :disabled="isokDisable" @click="nutritiveData()">确认</el-button>
  616. </div>
  617. </div>
  618. </el-dialog>
  619. </div>
  620. </template>
  621. <script>
  622. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetDataByNames, checkButtons } from '@/api/common'
  623. import Cookies from 'js-cookie'
  624. import Pagination from '@/components/Pagination'
  625. import { MessageBox } from 'element-ui'
  626. export default {
  627. name: 'FeedTable',
  628. components: { Pagination },
  629. directives: {
  630. limit: {
  631. // 指令的定义
  632. update: function(el) {
  633. el.onkeypress = function(e) {
  634. var code = e.charCode
  635. if (code != 0) {
  636. if (!String.fromCharCode(code).match(/[0-9\.]/)) {
  637. return false
  638. }
  639. }
  640. }
  641. el.addEventListener('textInput', function(e) {
  642. e.target.value = e.target.value.replace(/[^0-9\.]/g, '')
  643. })
  644. el.onkeyup = function(e) {
  645. e.target.value = e.target.value.replace(/[^0-9\.]/g, '')
  646. }
  647. }
  648. }
  649. },
  650. data() {
  651. return {
  652. isRoleEdit: [],
  653. requestParams: [
  654. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['跳转延时'] },
  655. { name: 'getFeedclassByBig', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  656. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['计划类型'] },
  657. { name: 'getTMRListEnableType', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid'), eqtype: '4' }}
  658. ],
  659. enableList: [{ id: '1', name: '是' }, { id: '0', name: '否' }], // 是否启用
  660. feedSourcesList: [{ id: '0', name: '系统内置' }, { id: '1', name: '用户自定义' }], // 饲料来源
  661. confirmStartList: [{ id: '0', name: '禁用' }, { id: '1', name: '启用' }], // 确认开始
  662. associationStatusList: [{ id: '1', name: '是' }, { id: '0', name: '否' }], // 关联状态
  663. jumpDelayList: [], // 跳转延时
  664. feedTypeList: [], // 饲料分类
  665. planTypeList: [], // 计划类型
  666. smallMaterialList: [], // 小料秤
  667. jmpList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 无上域
  668. table: {
  669. tableKey: 0,
  670. list: [],
  671. total: 0,
  672. listLoading: true,
  673. getdataListParm: {
  674. name: 'getFeedList',
  675. page: 1,
  676. offset: 1,
  677. pagecount: 10,
  678. returntype: 'Map',
  679. parammaps: {
  680. pastureid: Cookies.get('pastureid'),
  681. fname: '',
  682. fclassid: '',
  683. source: '',
  684. autozone: '',
  685. autosecond: '',
  686. allowratio: '',
  687. printgroup: '',
  688. enable: ''
  689. }
  690. }
  691. },
  692. // 多项搜索显示隐藏
  693. arrowDown: true,
  694. arrowUp: false,
  695. // 新增/编辑
  696. create: {
  697. dialogFormVisible: false,
  698. dialogStatus: '',
  699. temp: { pastureid: Cookies.get('pastureid'), fname: '', fclassid: '', fclass: '', feedcode: '', source: '用户自定义', printgroupid: '1', printgroup: '无', unitweight: '', uprice: '', allowratio: '', autozone: '', autosecond: '0', autosecondname: '禁用', confirmstart: '0', confirmstartname: '禁用', enable: '1', trgaddress: '', backup1: '', backup2: '', backup3: '' },
  700. rules: {
  701. fname: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  702. fclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  703. feedcode: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  704. }
  705. },
  706. // 饲料库
  707. feedBank: {
  708. dialogFormVisible: false,
  709. dialogStatus: '',
  710. temp: {},
  711. rules: {},
  712. tableKey: 0,
  713. list: [],
  714. total: 0,
  715. listLoading: true,
  716. getdataListParm: {
  717. name: 'getFeednurList',
  718. page: 1,
  719. offset: 1,
  720. returntype: 'Map',
  721. parammaps: {
  722. pastureid: Cookies.get('pastureid'),
  723. fname: '',
  724. statue: ''
  725. }
  726. }
  727. },
  728. // 关联
  729. relation: {
  730. dialogFormVisible: false,
  731. dialogStatus: '',
  732. temp: {},
  733. rules: {},
  734. tableKey: 0,
  735. list: [],
  736. total: 0,
  737. listLoading: true,
  738. getdataListParm: {
  739. name: 'getFeednurRelation',
  740. page: 1,
  741. offset: 1,
  742. returntype: 'Map',
  743. parammaps: {
  744. pastureid: Cookies.get('pastureid'),
  745. fname: ''
  746. }
  747. }
  748. },
  749. // 营养价值
  750. nutritive: {
  751. dialogFormVisible: false,
  752. dialogStatus: '',
  753. temp: {},
  754. rules: {}
  755. },
  756. textMap: {
  757. create: '新增',
  758. update: '编辑',
  759. feedBank: '饲料库',
  760. relation: '关联',
  761. nutritive: '营养价值'
  762. },
  763. isokDisable: false,
  764. selectList: [],
  765. requestParam: {},
  766. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  767. cellStyle: { padding: 0 + 'px' }
  768. }
  769. },
  770. mounted() {
  771. document.addEventListener('click', (e) => {
  772. if (this.$refs.selectInput !== undefined) {
  773. if (!this.$refs.selectInput.contains(e.target)) {
  774. this.arrowDown = true
  775. this.arrowUp = false
  776. } else {
  777. this.arrowDown = false
  778. this.arrowUp = true
  779. }
  780. }
  781. })
  782. },
  783. created() {
  784. this.getList()
  785. this.getDownList()
  786. this.getButtons()
  787. },
  788. methods: {
  789. getButtons() {
  790. const Edit = 'FeedTable'
  791. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  792. this.isRoleEdit = isRoleEdit
  793. },
  794. getDownList() {
  795. GetDataByNames(this.requestParams).then(response => {
  796. this.jumpDelayList = response.data.getDictByName.list
  797. this.feedTypeList = response.data.getFeedclassByBig.list
  798. this.planTypeList = response.data.getDictByName2.list
  799. this.smallMaterialList = response.data.getTMRListEnableType.list
  800. })
  801. },
  802. getList() {
  803. this.table.listLoading = true
  804. GetDataByName(this.table.getdataListParm).then(response => {
  805. console.log('table数据', response.data.list)
  806. if (response.data.list !== null) {
  807. this.table.list = response.data.list
  808. this.table.pageNum = response.data.pageNum
  809. this.table.pageSize = response.data.pageSize
  810. this.table.total = response.data.total
  811. } else {
  812. this.table.list = []
  813. }
  814. setTimeout(() => {
  815. this.table.listLoading = false
  816. }, 100)
  817. })
  818. },
  819. handleSearch() {
  820. console.log('点击了查询')
  821. this.table.getdataListParm.offset = 1
  822. this.getList()
  823. this.arrowDown = true
  824. this.arrowUp = false
  825. },
  826. handleRefresh() {
  827. console.log('点击了重置')
  828. this.table.getdataListParm.parammaps.fname = ''
  829. this.table.getdataListParm.parammaps.fclassid = ''
  830. this.table.getdataListParm.parammaps.source = ''
  831. this.table.getdataListParm.parammaps.autozone = ''
  832. this.table.getdataListParm.parammaps.autosecond = ''
  833. this.table.getdataListParm.parammaps.allowratio = ''
  834. this.table.getdataListParm.parammaps.printgroup = ''
  835. this.table.getdataListParm.parammaps.enable = ''
  836. this.table.getdataListParm.offset = 1
  837. this.getList()
  838. },
  839. resetTemp() {
  840. this.create.temp = { pastureid: Cookies.get('pastureid'), fname: '', fclassid: '', fclass: '', feedcode: '', source: '用户自定义', printgroupid: '1', printgroup: '无', unitweight: '', uprice: '', allowratio: '', autozone: '', autosecond: '0', autosecondname: '禁用', confirmstart: '0', confirmstartname: '禁用', enable: '1', trgaddress: '', backup1: '', backup2: '', backup3: '', jmp: '0' }
  841. },
  842. // 计划类型
  843. changePlanList(item) {
  844. this.create.temp.printgroup = this.planTypeList.find(obj => obj.value === item).label
  845. },
  846. // 饲料类型
  847. changeFeedList(item) {
  848. this.create.temp.fclass = this.feedTypeList.find(obj => obj.id === item).mixname
  849. },
  850. // 跳转延时
  851. changeAutosecond(item) {
  852. this.create.temp.autosecondname = this.jumpDelayList.find(obj => obj.value === item).label
  853. },
  854. // 确认开始
  855. changeConfirmstart(item) {
  856. this.create.temp.confirmstartname = this.confirmStartList.find(obj => obj.id === item).name
  857. },
  858. changeSmallMaterial(item) {
  859. if (item !== '') {
  860. this.create.temp.smtmrname = this.smallMaterialList.find(obj => obj.id === item).tname
  861. } else {
  862. this.create.temp.smtmrname = ''
  863. }
  864. },
  865. // 新增
  866. handleCreate() {
  867. console.log('点击了新增')
  868. this.resetTemp()
  869. this.create.dialogStatus = 'create'
  870. this.create.dialogFormVisible = true
  871. },
  872. createData() {
  873. console.log('点击了新增保存')
  874. this.isokDisable = true
  875. setTimeout(() => {
  876. this.isokDisable = false
  877. }, 1000)
  878. this.$refs['temp'].validate(valid => {
  879. if (valid) {
  880. const unitweight = /^[1-9]\d*$/
  881. if (this.create.temp.unitweight !== '') {
  882. if (!unitweight.test(parseFloat(this.create.temp.unitweight))) {
  883. this.$message({ type: 'error', message: '包装单位重量请输入正整数', duration: 2000 })
  884. return false
  885. }
  886. }
  887. const uprice = /^\d+(\.\d{1,2})?$/
  888. if (this.create.temp.uprice !== '') {
  889. if (!uprice.test(parseFloat(this.create.temp.uprice))) {
  890. this.$message({ type: 'error', message: '单价请保留两位小数', duration: 2000 })
  891. return false
  892. }
  893. }
  894. if (this.create.temp.autozone !== '') {
  895. const autozone = /^([0-9]|(1[0-9]|2[0-9]|3[0-9]|4[0-9]|(50)))$/
  896. if (!autozone.test(parseFloat(this.create.temp.autozone))) {
  897. this.$message({ type: 'error', message: '跳转重量域请输入大于等于0小于等于50的整数', duration: 2000 })
  898. return false
  899. }
  900. } else {
  901. this.create.temp.autozone = '0'
  902. }
  903. if (this.create.temp.trgaddress.length > 8) {
  904. this.$message({ type: 'error', message: '继电器位置请输入1-8位数字', duration: 2000 })
  905. return false
  906. }
  907. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  908. if (pattern.test(this.create.temp.fname)) {
  909. this.$message({ type: 'error', message: '饲料名称不可输入特殊字符', duration: 2000 })
  910. return false
  911. }
  912. const allowratio = /^[0-9]\d*$/
  913. if (this.create.temp.allowratio !== '') {
  914. if (!allowratio.test(parseFloat(this.create.temp.allowratio))) {
  915. this.$message({ type: 'error', message: '允许误差数请输入大于等于0的整数', duration: 2000 })
  916. return false
  917. }
  918. }
  919. this.isokDisable = true
  920. setTimeout(() => {
  921. this.isokDisable = false
  922. }, 1000)
  923. this.requestParam.name = 'insertFeed'
  924. this.requestParam.parammaps = this.create.temp
  925. if (this.create.temp.allowratio == '') { this.create.temp.allowratio = '0' }
  926. if (this.create.temp.uprice == '') { this.create.temp.uprice = '0' }
  927. if (this.create.temp.unitweight == '') { this.create.temp.unitweight = '0' }
  928. if (this.create.temp.autozone == '') { this.create.temp.autozone = '0' }
  929. if (this.create.temp.trgaddress == '') { this.create.temp.trgaddress = '0' }
  930. PostDataByName(this.requestParam).then(response => {
  931. console.log('新增保存发送参数', this.requestParam)
  932. if (response.msg !== 'fail') {
  933. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  934. this.create.dialogFormVisible = false
  935. this.getList()
  936. } else {
  937. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  938. if (this.create.temp.allowratio == '0') { this.create.temp.allowratio = '' }
  939. if (this.create.temp.uprice == '0') { this.create.temp.uprice = '' }
  940. if (this.create.temp.unitweight == '0') { this.create.temp.unitweight = '' }
  941. if (this.create.temp.autozone == '0') { this.create.temp.autozone = '' }
  942. if (this.create.temp.trgaddress == '0') { this.create.temp.trgaddress = '' }
  943. }
  944. })
  945. }
  946. })
  947. },
  948. // 编辑
  949. handleUpdate(row) {
  950. console.log('点击了编辑', row)
  951. this.create.dialogStatus = 'update'
  952. this.create.dialogFormVisible = true
  953. row.fclassid = String(row.fclassid)
  954. row.printgroupid = String(row.printgroupid)
  955. row.autosecond = String(row.autosecond)
  956. row.confirmstart = String(row.confirmstart)
  957. row.enable = String(row.enable)
  958. row.jmp = String(row.jmp)
  959. this.create.temp = Object.assign({}, row)
  960. if (this.create.temp.allowratio == '0') { this.create.temp.allowratio = '' }
  961. if (this.create.temp.uprice == '0.00') { this.create.temp.uprice = '' }
  962. if (this.create.temp.unitweight == '0') { this.create.temp.unitweight = '' }
  963. if (this.create.temp.autozone == '0') { this.create.temp.autozone = '' }
  964. if (this.create.temp.trgaddress == '0') { this.create.temp.trgaddress = '' }
  965. if (this.create.temp.smtmrid == '-1') { this.create.temp.smtmrid = '' }
  966. },
  967. updateData() {
  968. console.log('点击了编辑保存')
  969. this.isokDisable = true
  970. setTimeout(() => {
  971. this.isokDisable = false
  972. }, 1000)
  973. this.$refs['temp'].validate(valid => {
  974. if (valid) {
  975. const unitweight = /^[1-9]\d*$/
  976. if (this.create.temp.unitweight !== '') {
  977. if (!unitweight.test(parseFloat(this.create.temp.unitweight))) {
  978. this.$message({ type: 'error', message: '包装单位重量请输入正整数', duration: 2000 })
  979. return false
  980. }
  981. }
  982. const uprice = /^\d+(\.\d{1,2})?$/
  983. if (this.create.temp.uprice !== '') {
  984. if (!uprice.test(parseFloat(this.create.temp.uprice))) {
  985. this.$message({ type: 'error', message: '单价请保留两位小数', duration: 2000 })
  986. return false
  987. }
  988. }
  989. if (this.create.temp.autozone !== '') {
  990. const autozone = /^([0-9]|(1[0-9]|2[0-9]|3[0-9]|4[0-9]|(50)))$/
  991. if (!autozone.test(parseFloat(this.create.temp.autozone))) {
  992. this.$message({ type: 'error', message: '跳转重量域请输入大于等于0小于等于50的整数', duration: 2000 })
  993. return false
  994. }
  995. } else {
  996. this.create.temp.autozone = '0'
  997. }
  998. if (this.create.temp.trgaddress.length > 8) {
  999. this.$message({ type: 'error', message: '继电器位置请输入1-8位数字', duration: 2000 })
  1000. return false
  1001. }
  1002. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  1003. if (pattern.test(this.create.temp.fname)) {
  1004. this.$message({ type: 'error', message: '饲料名称不可输入特殊字符', duration: 2000 })
  1005. return false
  1006. }
  1007. const allowratio = /^[0-9]\d*$/
  1008. if (this.create.temp.allowratio !== '') {
  1009. if (!allowratio.test(parseFloat(this.create.temp.allowratio))) {
  1010. this.$message({ type: 'error', message: '允许误差数请输入大于等于0的整数', duration: 2000 })
  1011. return false
  1012. }
  1013. }
  1014. this.isokDisable = true
  1015. setTimeout(() => {
  1016. this.isokDisable = false
  1017. }, 1000)
  1018. this.requestParam.name = 'updateFeed'
  1019. this.requestParam.parammaps = this.create.temp
  1020. if (this.create.temp.allowratio == '') { this.create.temp.allowratio = '0' }
  1021. if (this.create.temp.uprice == '') { this.create.temp.uprice = '0' }
  1022. if (this.create.temp.unitweight == '') { this.create.temp.unitweight = '0' }
  1023. if (this.create.temp.autozone == '') { this.create.temp.autozone = '0' }
  1024. if (this.create.temp.trgaddress == '') { this.create.temp.trgaddress = '0' }
  1025. PostDataByName(this.requestParam).then(response => {
  1026. console.log('新增保存发送参数', this.requestParam)
  1027. if (response.msg !== 'fail') {
  1028. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1029. this.create.dialogFormVisible = false
  1030. this.getList()
  1031. } else {
  1032. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1033. if (this.create.temp.allowratio == '0') { this.create.temp.allowratio = '' }
  1034. if (this.create.temp.uprice == '0') { this.create.temp.uprice = '' }
  1035. if (this.create.temp.unitweight == '0') { this.create.temp.unitweight = '' }
  1036. if (this.create.temp.autozone == '0') { this.create.temp.autozone = '' }
  1037. if (this.create.temp.trgaddress == '0') { this.create.temp.trgaddress = '' }
  1038. }
  1039. })
  1040. }
  1041. })
  1042. },
  1043. // 饲料库
  1044. handleFeedBank() {
  1045. console.log('点击了饲料库')
  1046. this.feedBank.dialogStatus = 'feedBank'
  1047. this.feedBank.dialogFormVisible = true
  1048. this.getFeedBankList()
  1049. },
  1050. getFeedBankList() {
  1051. this.feedBank.listLoading = true
  1052. GetDataByName(this.feedBank.getdataListParm).then(response => {
  1053. console.log('table数据', response.data.list)
  1054. if (response.data.list !== null) {
  1055. this.feedBank.list = response.data.list
  1056. this.feedBank.pageNum = response.data.pageNum
  1057. this.feedBank.pageSize = response.data.pageSize
  1058. this.feedBank.total = response.data.total
  1059. } else {
  1060. this.feedBank.list = []
  1061. }
  1062. setTimeout(() => {
  1063. this.feedBank.listLoading = false
  1064. }, 100)
  1065. })
  1066. },
  1067. handleFeedBankSearch() {
  1068. console.log('点击了饲料库搜索')
  1069. this.getFeedBankList()
  1070. this.feedBank.getdataListParm.offset = 1
  1071. },
  1072. handleFeedBankRefresh() {
  1073. console.log('点击了饲料库重置')
  1074. this.feedBank.getdataListParm.parammaps.fname = ''
  1075. this.feedBank.getdataListParm.parammaps.statue = ''
  1076. this.getFeedBankList()
  1077. },
  1078. // 关联
  1079. handleRelation(row) {
  1080. console.log('点击了关联')
  1081. this.relation.dialogStatus = 'relation'
  1082. this.relation.dialogFormVisible = true
  1083. this.relation.temp = Object.assign({}, row)
  1084. this.relation.getdataListParm.parammaps.fid = this.relation.temp.id
  1085. this.getRelationList()
  1086. },
  1087. getRelationList() {
  1088. this.relation.listLoading = true
  1089. GetDataByName(this.relation.getdataListParm).then(response => {
  1090. console.log('table数据', response.data.list)
  1091. if (response.data.list !== null) {
  1092. this.relation.list = response.data.list
  1093. this.relation.pageNum = response.data.pageNum
  1094. this.relation.pageSize = response.data.pageSize
  1095. this.relation.total = response.data.total
  1096. } else {
  1097. this.relation.list = []
  1098. }
  1099. setTimeout(() => {
  1100. this.relation.listLoading = false
  1101. }, 100)
  1102. })
  1103. },
  1104. handleRelationSearch() {
  1105. console.log('点击了关联搜索')
  1106. this.relation.getdataListParm.offset = 1
  1107. this.getRelationList()
  1108. },
  1109. disassociateData(row) {
  1110. console.log('点击了取消关联')
  1111. MessageBox.confirm('是否确认取消关联?', {
  1112. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1113. }).then(() => {
  1114. this.isokDisable = true
  1115. setTimeout(() => {
  1116. this.isokDisable = false
  1117. }, 1000)
  1118. this.requestParam.name = 'updateFeedrelation'
  1119. this.requestParam.parammaps = {}
  1120. this.requestParam.parammaps.pastureid = this.relation.temp.pastureid
  1121. this.requestParam.parammaps.fid = this.relation.temp.id
  1122. this.requestParam.parammaps.id = row.id
  1123. PostDataByName(this.requestParam).then(response => {
  1124. console.log('取消关联保存发送参数', this.requestParam)
  1125. if (response.msg !== 'fail') {
  1126. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1127. this.getRelationList()
  1128. this.getList()
  1129. } else {
  1130. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1131. }
  1132. })
  1133. }).catch(() => {
  1134. this.$message({ type: 'info', message: '已取消' })
  1135. })
  1136. },
  1137. relationData(row) {
  1138. console.log('点击了关联保存')
  1139. MessageBox.confirm('是否确认关联?', {
  1140. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1141. }).then(() => {
  1142. this.isokDisable = true
  1143. setTimeout(() => {
  1144. this.isokDisable = false
  1145. }, 1000)
  1146. this.requestParam.name = 'insertFeednur'
  1147. this.requestParam.parammaps = {}
  1148. this.requestParam.parammaps.pastureid = this.relation.temp.pastureid
  1149. this.requestParam.parammaps.fid = this.relation.temp.id
  1150. this.requestParam.parammaps.fname = this.relation.temp.fname
  1151. this.requestParam.parammaps.feedcode = this.relation.temp.feedcode
  1152. this.requestParam.parammaps.price = row.price
  1153. this.requestParam.parammaps.remark = row.remark
  1154. this.requestParam.parammaps.dry = row.dry
  1155. this.requestParam.parammaps.starch = row.starch
  1156. this.requestParam.parammaps.cp = row.cp
  1157. this.requestParam.parammaps.ca = row.ca
  1158. this.requestParam.parammaps.p = row.p
  1159. this.requestParam.parammaps.n = row.n
  1160. this.requestParam.parammaps.fat = row.fat
  1161. this.requestParam.parammaps.adf = row.adf
  1162. this.requestParam.parammaps.ndf = row.ndf
  1163. this.requestParam.parammaps.ndip = row.ndip
  1164. this.requestParam.parammaps.ash = row.ash
  1165. this.requestParam.parammaps.fpercent = row.fpercent
  1166. this.requestParam.parammaps.iscu = row.iscu
  1167. this.requestParam.parammaps.feednurid = row.id
  1168. PostDataByName(this.requestParam).then(response => {
  1169. console.log('关联保存发送参数', this.requestParam)
  1170. if (response.msg !== 'fail') {
  1171. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1172. this.getRelationList()
  1173. this.getList()
  1174. } else {
  1175. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1176. }
  1177. })
  1178. }).catch(() => {
  1179. this.$message({ type: 'info', message: '已取消' })
  1180. })
  1181. },
  1182. // 营养价值
  1183. handleNutritive(row) {
  1184. console.log('点击了营养价值', row)
  1185. this.nutritive.dialogStatus = 'nutritive'
  1186. this.nutritive.dialogFormVisible = true
  1187. this.nutritive.temp = Object.assign({}, row)
  1188. },
  1189. nutritiveData() {
  1190. console.log('点击了营养价值保存')
  1191. this.isokDisable = true
  1192. setTimeout(() => {
  1193. this.isokDisable = false
  1194. }, 1000)
  1195. if (this.nutritive.temp.dry == undefined) { this.$set(this.nutritive.temp, 'dry', '') }
  1196. if (this.nutritive.temp.starch == undefined) { this.$set(this.nutritive.temp, 'starch', '') }
  1197. if (this.nutritive.temp.cp == undefined) { this.$set(this.nutritive.temp, 'cp', '') }
  1198. if (this.nutritive.temp.ca == undefined) { this.$set(this.nutritive.temp, 'ca', '') }
  1199. if (this.nutritive.temp.p == undefined) { this.$set(this.nutritive.temp, 'p', '') }
  1200. if (this.nutritive.temp.n == undefined) { this.$set(this.nutritive.temp, 'n', '') }
  1201. if (this.nutritive.temp.fat == undefined) { this.$set(this.nutritive.temp, 'fat', '') }
  1202. if (this.nutritive.temp.adf == undefined) { this.$set(this.nutritive.temp, 'adf', '') }
  1203. if (this.nutritive.temp.ndf == undefined) { this.$set(this.nutritive.temp, 'ndf', '') }
  1204. if (this.nutritive.temp.ndip == undefined) { this.$set(this.nutritive.temp, 'ndip', '') }
  1205. if (this.nutritive.temp.ash == undefined) { this.$set(this.nutritive.temp, 'ash', '') }
  1206. var positiveNumber = /^\d+(\.\d{1,2})?$/
  1207. if (this.nutritive.temp.dry !== '') {
  1208. if (!positiveNumber.test(parseFloat(this.nutritive.temp.dry))) {
  1209. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1210. return false
  1211. }
  1212. }
  1213. console.log(this.nutritive.temp.starch)
  1214. if (this.nutritive.temp.starch !== '') {
  1215. if (!positiveNumber.test(parseFloat(this.nutritive.temp.starch))) {
  1216. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1217. return false
  1218. }
  1219. }
  1220. if (this.nutritive.temp.cp !== '') {
  1221. if (!positiveNumber.test(parseFloat(this.nutritive.temp.cp))) {
  1222. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1223. return false
  1224. }
  1225. }
  1226. if (this.nutritive.temp.ca !== '') {
  1227. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ca))) {
  1228. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1229. return false
  1230. }
  1231. }
  1232. if (this.nutritive.temp.p !== '') {
  1233. if (!positiveNumber.test(parseFloat(this.nutritive.temp.p))) {
  1234. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1235. return false
  1236. }
  1237. }
  1238. if (this.nutritive.temp.n !== '') {
  1239. if (!positiveNumber.test(parseFloat(this.nutritive.temp.n))) {
  1240. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1241. return false
  1242. }
  1243. }
  1244. if (this.nutritive.temp.fat !== '') {
  1245. if (!positiveNumber.test(parseFloat(this.nutritive.temp.fat))) {
  1246. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1247. return false
  1248. }
  1249. }
  1250. if (this.nutritive.temp.adf !== '') {
  1251. if (!positiveNumber.test(parseFloat(this.nutritive.temp.adf))) {
  1252. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1253. return false
  1254. }
  1255. }
  1256. if (this.nutritive.temp.ndf !== '') {
  1257. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ndf))) {
  1258. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1259. return false
  1260. }
  1261. }
  1262. if (this.nutritive.temp.ndip !== '') {
  1263. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ndip))) {
  1264. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1265. return false
  1266. }
  1267. }
  1268. if (this.nutritive.temp.ash !== '') {
  1269. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ash))) {
  1270. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1271. return false
  1272. }
  1273. }
  1274. this.requestParam.name = 'insertFeednur'
  1275. this.requestParam.parammaps = {}
  1276. this.requestParam.parammaps.pastureid = this.nutritive.temp.pastureid
  1277. this.requestParam.parammaps.fid = this.nutritive.temp.id
  1278. this.requestParam.parammaps.fname = this.nutritive.temp.fname
  1279. this.requestParam.parammaps.feedcode = this.nutritive.temp.feedcode
  1280. this.requestParam.parammaps.price = this.nutritive.temp.uprice
  1281. this.requestParam.parammaps.remark = this.nutritive.temp.remark
  1282. this.requestParam.parammaps.dry = this.nutritive.temp.dry
  1283. this.requestParam.parammaps.starch = this.nutritive.temp.starch
  1284. this.requestParam.parammaps.cp = this.nutritive.temp.cp
  1285. this.requestParam.parammaps.ca = this.nutritive.temp.ca
  1286. this.requestParam.parammaps.p = this.nutritive.temp.p
  1287. this.requestParam.parammaps.n = this.nutritive.temp.n
  1288. this.requestParam.parammaps.fat = this.nutritive.temp.fat
  1289. this.requestParam.parammaps.adf = this.nutritive.temp.adf
  1290. this.requestParam.parammaps.ndf = this.nutritive.temp.ndf
  1291. this.requestParam.parammaps.ndip = this.nutritive.temp.ndip
  1292. this.requestParam.parammaps.ash = this.nutritive.temp.ash
  1293. this.requestParam.parammaps.fpercent = this.nutritive.temp.fpercent
  1294. this.requestParam.parammaps.iscu = this.nutritive.temp.iscu
  1295. this.requestParam.parammaps.feednurid = '-1'
  1296. PostDataByName(this.requestParam).then(response => {
  1297. console.log('关联保存发送参数', this.requestParam)
  1298. if (response.msg !== 'fail') {
  1299. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1300. this.getList()
  1301. this.nutritive.dialogFormVisible = false
  1302. } else {
  1303. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1304. }
  1305. })
  1306. },
  1307. // 行内删除
  1308. handleRowDelete(row) {
  1309. console.log('点击了行内删除')
  1310. MessageBox.confirm('是否确认删除此信息?', {
  1311. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1312. }).then(() => {
  1313. this.selectList = []
  1314. this.requestParam = {}
  1315. this.requestParam.common = { 'returnmap': '0' }
  1316. this.requestParam.data = []
  1317. this.requestParam.data[0] = { 'name': 'checkDeleteFeed', 'type': 'v', 'parammaps': {
  1318. 'pastureid': row.pastureid,
  1319. 'id': row.id
  1320. }}
  1321. this.requestParam.data[1] = { 'name': 'deleteFeed', 'type': 'e', 'parammaps': {
  1322. 'pastureid': row.pastureid,
  1323. 'id': row.id
  1324. }}
  1325. ExecDataByConfig(this.requestParam).then(response => {
  1326. console.log('删除保存发送参数', this.requestParam)
  1327. if (response.msg === 'fail') {
  1328. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1329. } else {
  1330. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1331. this.getList()
  1332. }
  1333. })
  1334. }).catch(() => {
  1335. this.$message({ type: 'info', message: '已取消删除' })
  1336. })
  1337. },
  1338. handleSelectionChange(val) {
  1339. console.log('勾选数据', val)
  1340. this.selectList = val
  1341. },
  1342. // 多项删除
  1343. handleDelete() {
  1344. console.log('点击了删除')
  1345. if (this.selectList.length == 0) {
  1346. this.$message({ type: 'error', message: '请选择饲料表信息', duration: 2000 })
  1347. } else {
  1348. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  1349. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1350. }).then(() => {
  1351. this.requestParam = {}
  1352. this.requestParam.common = { 'returnmap': '0' }
  1353. this.requestParam.data = []
  1354. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1355. this.requestParam.data[0].children = []
  1356. this.requestParam.data[0].children[0] = { 'name': 'checkDeleteFeed', 'type': 'v', 'parammaps': {
  1357. id: '@insertSpotList.id',
  1358. pastureid: '@insertSpotList.pastureid'
  1359. }}
  1360. this.requestParam.data[0].children[1] = { 'name': 'deleteFeed', 'type': 'e', 'parammaps': {
  1361. id: '@insertSpotList.id',
  1362. pastureid: '@insertSpotList.pastureid'
  1363. }}
  1364. ExecDataByConfig(this.requestParam).then(response => {
  1365. console.log('删除保存发送参数', this.requestParam)
  1366. if (response.msg === 'fail') {
  1367. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1368. } else {
  1369. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1370. this.getList()
  1371. }
  1372. })
  1373. })
  1374. }
  1375. }
  1376. }
  1377. }
  1378. </script>
  1379. <style lang="scss" scoped>
  1380. .search{margin-top:10px;}
  1381. .table{margin-top:10px;}
  1382. $width:350px;
  1383. $left:325px;
  1384. .selectInput{
  1385. position: relative;
  1386. display: inline-block;
  1387. .Input{width: $width;position: relative;}
  1388. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  1389. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  1390. .selectUl{
  1391. 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;
  1392. li{
  1393. 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;
  1394. a{float:left;width: 80px;}
  1395. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  1396. }
  1397. }
  1398. }
  1399. </style>