700cd7160c0e9a77506e08678eb4bbfb6b8067d5.svn-base 66 KB

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